home *** CD-ROM | disk | FTP | other *** search
/ Amoszine PD Edition 0 / Amoszine PD Edition 0.adf / SOURCE_CODE / EZ-Paint.AMOS / EZ-Paint.amosSourceCode < prev    next >
AMOS Source Code  |  1993-02-25  |  131KB  |  3,701 lines

  1. 'Ok dudes this is NOT a complete program and it has a few bugs but there 
  2. 'is a lot to be learnt from this program for the beinner.  
  3. 'steve.
  4. '
  5. '
  6. ' ALAN CARTER 92 
  7. '
  8. '  A VERY simple proggy written to demonstrate features to some people new 
  9. '  to AMOS.  Ignore any patronising remarks if your past this stage! 
  10. '  
  11. '
  12. Close Workbench 
  13. Close Editor 
  14. '
  15. '  Open two low resolution screens.  Screen 0 is used as the main drawing  
  16. '  screen.  Screen 1 is for holding temporary images that can be copied back 
  17. '  to Screen 0 when the undo feature is used.  
  18. '
  19. Screen Open 0,320,276,64,Lowres : Paper 0 : Curs Off : Flash Off : Cls 
  20. Screen Open 1,320,276,64,Lowres : Paper 0 : Curs Off : Flash Off : Cls 
  21. '
  22. '  Set the drawing pointer to screen 0 
  23. '
  24. Screen 0
  25. '
  26. '  Change the mouse image to a clock to tell the user to wait  
  27. '
  28. Change Mouse 3
  29. '
  30. '  Load the colour palette of our menu panel into Screen 0 
  31. '    
  32. Get Sprite Palette 
  33. '
  34. '  Set the drawing pointer to screen 1 
  35. '
  36. Screen 1 : 
  37. '
  38. '  And load the colour palette into this screen  
  39. '
  40. Get Sprite Palette 
  41. '
  42. '  Now bring screen 0 back to the front of the display, and set the drawing  
  43. '  pointer back to screen 0, ready to use for drawing  
  44. '
  45. Screen To Front 0 : Screen 0
  46. '
  47. '  Tell the computer to bring a menu bank stored in bank 6 and put it into 
  48. '  our menu.  Then switch the menu on. 
  49. '
  50. Bank To Menu 6
  51. Menu On 
  52. '
  53. '  Now we dimension some arrays that will be used for fairly important 
  54. '  tasks later in the program.   
  55. '
  56. Dim FAME$(50),C(7),C2(7),C3(7),SX(7),ST(7),NC(7),RGB(63),REZ$(7),OK$(1)
  57. Dim TPAL(15),AN$(20),O$(1)
  58. '
  59. '  Because we are using some procedures, any variables that need to be used  
  60. '  by other parts of the program must be shared, so we use 'Shared' to let 
  61. '  the computer know that they shouldn't be kept by the procedures.  
  62. '
  63. Shared FAME$(),HFLIP,VFLIP,BX,BY,BX1,BY1,FIN$,PAGE,F2TYPE,F5TYPE,F6TYPE,F7TYPE,F8TYPE
  64. Shared XB,YB,BO,T,F2,F5,F6,F7,F8,F9,F13,CROSS,COORDS,I,PROG,FRESH,COUNT,FILENAME$,FC,BC
  65. Shared WIDTH,HEIGHT,PAGE$,DENSITY
  66. '
  67. '  And now just set up some variables that will be needed elsewhere. 
  68. '  e.g. The variable I is the starting ink colour and is set to colour 4 
  69. '
  70. COORDS=0 : I=4 : COUNT=1 : FILENAME$="" : Dir$="df0:" : PAGE=0 : NTS=-Ntsc
  71. NCOLS=32 : XSIZE=32 : YSIZE=32 : FC=1 : BC=2 : DENSITY=50
  72. '
  73. '  This simple command limits the mouse to the dimensions of your T.V display
  74. '
  75. Limit Mouse 129,42 To 444,304
  76. '  
  77. '  Now we call our first procedure.  This holds all the information that will
  78. '  draw the menu and title bars, and set up the various zones for these bars.
  79. '    
  80. Proc SETUPSCREEN
  81. '
  82. '  This line simply puts the starting message on the title bar in ink a
  83. '  black ink colour. We do this now because the next lines will take a 
  84. '  few seconds to complete, and the user must know that the program is working 
  85. '
  86. Ink 0 : Text 7,7,"EasyPaint   Initialising"
  87. '
  88. '  This copies an exact replica of the starting screen to screen 1 
  89. '
  90. Screen Copy 0 To 1
  91. '
  92. '  And the next 2 lines copy an exact replica of the starting screen to
  93. '  memory banks 14 and 15.  The only difference from above is that we are  
  94. '  packing (compressing) the image, instead of just copying it.  This will 
  95. '  save a substantial amount of memory because the banks don't need a screen 
  96. '  opening for them.  The banks are used to store information that can be used 
  97. '  as a spare page for the using to flick between. 
  98. '
  99. 'Spack 0 To 14 
  100. 'Spack 0 To 15 
  101. '
  102. '  Now that done we can print our message a message to the user saying the 
  103. '  program is ready to use.
  104. '
  105. Ink 0 : Text 7,7,"EasyPaint   "+PAGE$+"    "
  106. '  
  107. '  And change the mouse back from the clock to a cross-hair. 
  108. '
  109. Change Mouse 2
  110. '
  111. '  Earlier we brought our menu from Memory bank 6, now we tell the computer
  112. '  what to do with this menu.  e.g.  The three titles - Picture, brush and 
  113. '  prefs are numbered 1,2 and 3.  So when the user chooses an option from  
  114. '  picture, the computer recognises this a choice from number 1.  It then  
  115. '  checks this next line to see what it should do. The procedure for these - 
  116. '  MECHECK1 etc are explained later.  It does this automatically - 
  117. '  (under interrupt) ... 
  118. '
  119. On Menu Proc MENCHECK1,MENCHECK2,MENCHECK3
  120. '
  121. '  ... After its been activated with this line 
  122. '
  123. On Menu On 
  124. '
  125. '  Now we come to what could be called the main program loop !  The beauty 
  126. '  of using procedures is it makes your program so much simpler to handle. 
  127. '  All this line does is call the procedure that checks the zones for tools
  128. '  like circle and line, and if they are selected, jumps to that procedure.
  129. '  It then starts all over again.
  130. '
  131. 1 Proc CHECKZONES
  132. Goto 1
  133. '  
  134. '  This is where all the little parts of the program are hidden away.  We
  135. '  call them procedures!  But you already knew that, right ?  If you are   
  136. '  reading this for the first time then the procedures will be closed -  
  137. '  that is, you will only see the title of the procedure.  To open them up 
  138. '  simply position the cursor on the procedures name with the mouse, and 
  139. '  then click up there ^^ the control panel where it says 'Fold/Unfold'
  140. '  This will open up the procedure for you to examine.  Just click it again
  141. '  to close, but make sure the cursor is somewhere inside the opened 
  142. '  procedure.
  143. '
  144. '  This procedure is responsible for drawing dotted freehand.  The next  
  145. '  line tells the computer that the following lines will all be part of the
  146. '  the procedure called FREHANDDOT until it encounters an 'End Proc' command.  
  147. '
  148. Procedure FREHANDDOT
  149. '
  150. '  This line check to see if the procedure has got by this part before.
  151. '  If it has then T will have been set to 1. If T doesn't equal 0 then it  
  152. '  pastes the bob highlighted in blue on the menu bar to show that the 
  153. '  dotted freehand tool has been selected.  Otherwise (else) jump to the 
  154. '  label 'BEGIN' 
  155. '
  156.    If T<>1 Then Paste Bob XB,YB,BO Else Goto BEGIN
  157. '
  158. '  Paste the highlighted freehand bob on the menu bar
  159. '
  160.    Paste Bob 292,36,20
  161. '
  162. '  Now its time just to store the X and Y locations of the bob location, the 
  163. '  bob number and set T to 1 to stop what we just mentioned above
  164.    XB=292 : YB=36 : BO=2 : T=1
  165. '
  166. '  And begin ... with a label. 
  167. '
  168.    BEGIN:
  169. '
  170. '  'Repeat' is used to start a piece of program looping,  further down you will
  171. '  see another command - 'Until'.  Basically it will just repeat until the 
  172. '  conditions we specify after the 'Until' command are met.
  173. '
  174.    Repeat 
  175. '
  176. '  While we are repeating, we will check to see if the left mouse key (1)
  177. '  is pressed at the same time the mouse pointer is off the drawing area - 
  178. '  (zone 0): If it is then we will jump to the end of this procedure,  
  179. '  signified by the label - FINISHED, which will then end this procedure 
  180. '  and go back to the main loop. 
  181. '
  182.       If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
  183. '
  184. '  Here is the 'Until' part of the 'Repeat' loop.  You can see that all we 
  185. '  are waiting for is for the mouse pointer to enter the drawing area- Zone 0  
  186. '  We do this as a check that the users selection is going to be used, and   
  187. '  not just deselected straight away.
  188. '
  189.    Until Mouse Zone=0
  190. '
  191. '  Next is a simple call to a simple procedure for a simple purpose!  This 
  192. '  makes a quick copy of the current picture into screen 1.  The purpose 
  193. '  being,  should the user draw something he doesn't like, he can simply 
  194. '  press the Undo button on the menu bar, and return the picture to the
  195. '  state it was it before he started before we just copied it into screen 1. 
  196. '  Jumping ahead of ourselves for a moment, all the undo procedure does is 
  197. '  copy screen 1 to screen 0 (the one the user sees). Simple eh ?
  198. '
  199.    _SCOPY
  200. '
  201. '  This is just a mid-procedure label, useful if you dont want to go through 
  202. '  all of the above again, or 'none of the above!!' in other words 
  203. '
  204.    BEGIN2:
  205. '
  206. '  Here we come across the PROG Variable.  We are setting it to 2.  Please 
  207. '  see the varible list for this program for more information. 
  208. '
  209.    PROG=2
  210. '
  211. '  Time to set another loop off, but this one is unconditional, i.e. it
  212. '  wont stop for nobody unless some line inbetween jumps out of it.  You 
  213. '  could use a Repeat/Until in here, but it's really being wasted if you 
  214. '  do.  The format it takes is simple ...
  215. '  'Do' is the start point of the loop 
  216. '
  217.    Do 
  218. '
  219. '  Then comes any program lines you want to cycle through indefinately.
  220. '  We are checking here to see if the COORDS variable is set to 1.  If it
  221. '  is then do a quick jump to the COORDS procedure.  The COORDS procedure only 
  222. '  prints the mouse co-ordinates on the menu bar once,  but in this loop 
  223. '  it gives the illusion of being constant!
  224. '
  225.       If COORDS=1 Then Proc COORDS
  226. '
  227. '  Now we do the same for the CROSS variable.  If it is set to one then do 
  228. '  a quick jump to the CROSSHAIRS procedure.  Again this just draws the  
  229. '  crosshairs on the screen once and comes straight back here.  You could
  230. '  pop down to these procedure now if you want, just for a quick look to 
  231. '  see what they are doing ! 
  232. '
  233.       If CROSS=1 Then Proc CROSSHAIRS
  234. '
  235. '  This line checks to see if you have pressed the mouse button on the 
  236. '  drawing area of the screen (zone 0).  When the program is running this
  237. '  is the time when you press the left button to start drawing.  So, if the
  238. '  user has pressed the button, we do a quick copy of the screen and put it
  239. '  in screen 1 ( yes, same as before), and then jump out of this loop to 
  240. '  the label BEGIN3
  241. '
  242.       If Mouse Key=1 and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
  243. '
  244. '  Another check on the mouse position here, this time to see if the mouse 
  245. '  has left the drawing area.  If it has then its time not only to leave this
  246. '  loop, but to leave this procedure.  It's a pretty good bet that the user
  247. '  has left the drawing area to select another function or change the ink
  248. '  colour etc. Either way, if he's out of the drawing area it's time to jump 
  249. '  to the end of the Dotted Freehand procedure, and the lable is the same
  250. '  for all of our procedures - FINISHED. 
  251. '
  252.       If Mouse Zone<>0 Then Goto FINISHED
  253. '
  254. '  'Loop' is the other part of the 'Do' command.  As you can see, it has no
  255. '  conditions and will continue looping until the program inbetween jumps out. 
  256. '
  257.    Loop 
  258. '
  259. '  Another mid-procedure label, saves us from going through the above again. 
  260. '  But this is the actual output part of this procedure.  Coming up is 
  261. '  what puts the dotted line on yout t.v.
  262. '
  263.    BEGIN3:
  264. '
  265. '  Hey!  Yet another loop already, and a different one at that.  This one  
  266. '  is the 'While'/'Wend' type, and this one is conditional, but the  
  267. '  conditions go after the 'While'.  You could use a 'Repeat'/'Until', but 
  268. '  for what we want to do that could prove to be a bit vague,  because this
  269. '  loop will only loop while the conditions are being met.  In other words 
  270. '  as soon as you stop pressing the left mouse key (key 1) the loop will 
  271. '  finish. 
  272. '  So we start the loop, and tell the computer that the conditions of the loop 
  273. '  will be - only repeat if the left mouse key is pressed ...
  274. '
  275.    While Mouse Key=1
  276. '
  277. '  You've seen the next line before, if the COORDS variable is set to 1 then 
  278. '  we do a quick jump to the COORDS procedure to print the co-ordinates
  279. '
  280.       If COORDS=1 Then Proc COORDS
  281. '
  282. '  Here it is, simplicity itself.  Remember, the computer wouldn't be  
  283. '  executing these lines if the user wasn't pressing the left mouse key. 
  284. '  So we make sure the ink colour is set to variable responsible for ink.
  285. '  And then plot a single pixel at the screen co-ordinates of the mouse. 
  286. '  If your unsure about screen co-ordinates, then see the Chapter in the 
  287. '  manual regarding SCREEN/HARDWARE co-ordinates.
  288. '
  289.       Ink I : Plot X Screen(X Mouse),Y Screen(Y Mouse)
  290. '
  291. '  And now a quicker than quick check to see if the user is being naughty. 
  292. '  We dont want him/her drawing all over our nice menu bar do we ?  So if
  293. '  the mouse pointer leaves the drawing area (zone 0) then we will end this
  294. '  procedure by jumping to the FINISHED label. 
  295. '
  296.       If Mouse Zone<>0 Then Goto FINISHED
  297. '
  298. '  The next line is as we said previously, it sends the computer back to 
  299. '  the beginning of this loop - the 'While' command, but only if the user  
  300. '  is pressing the left mouse button.  If he/she isn't then the computer 
  301. '  will move on to the next line ... 
  302. '  
  303.    Wend 
  304. '
  305. '  Okay, so far so good ?  But what if the user isn't currently pressing 
  306. '  the left mouse button ?  Simple, just look at where we are.  The user 
  307. '  hasn't left the drawing area,  he/she is just waiting or positioning the
  308. '  mouse ready to draw.  So we simply jump back into the middle of this
  309. '  procedure and keep checking.  We do this by jumping to the lable BEGIN2 
  310. '
  311.    Goto BEGIN2
  312. '
  313. '  Here is the FINISHED label. 
  314. '
  315.    FINISHED:
  316. '
  317. '  And the end of this particular procedure is signified by the command .. 
  318. '
  319. End Proc
  320. '
  321. '  This procedure is responsible for the continouse freehand option.  Again, 
  322. '  the next line tell the computer that all following lines will be part of  
  323. '  the procedure called CONTINUOUSFREEHAND until it encounters an 'End Proc' 
  324. '  command.
  325. '
  326. Procedure CONTINUOUSFREEHAND
  327. '
  328. '  A quick note about this procedure.  If you click twice on the continuous
  329. '  freehand icon on the menu bar you will see a filled shape.  The tells us
  330. '  that any shape drawn from then on will be filled with the current ink 
  331. '  colour.  This option will be referred too herewith as a multiple option.
  332. '  It means that the initial part of a multiple option procedure is slightly 
  333. '  more complex than usual, but not overly so.  Stick with me. 
  334. '
  335. '  The same as the previous Procedure,  if the variable T doesn't equal 2
  336. '  then paste the highlighted bob on the menu bar to show the user that the  
  337. '  feature has been selected 
  338. '  
  339.    If T<>2 Then Paste Bob XB,YB,BO
  340. '
  341. '  Please see the Variable table regarding EasyPaint for descriptions of 
  342. '  the following variables.
  343. '
  344.    If F2=1 and F2TYPE=1 Then Goto B
  345.    If F2=1 and F2TYPE=0 Then Goto A
  346.    If F2=2 and F2TYPE=0 Then Goto A
  347.    If F2=2 and F2TYPE=1 Then Goto B
  348. '
  349.    A:
  350. '
  351. '  Here we paste the highlighted bob for un-filled freehand
  352. '
  353.    Paste Bob 305,36,21
  354. '
  355. '  And set the co-ordinates and bob numbers into the same variables as 
  356. '  the last procedure.  It should be worth noting at this point, that most 
  357. '  of the actual drawing procedures share the same format and variables. 
  358. '  So it's wasteful repeating things all the time.  But where things are 
  359. '  similair, I'll bring them to your attention.
  360. '
  361.    XB=305 : YB=36 : BO=3 : T=2 : F2=1
  362. '
  363. '  We dont want to execute the next bit of program so we jump to the label 
  364. '  BEGIN, otherwise we will always end up pasting the filled freehand bob! 
  365. '
  366.    Goto BEGIN
  367. '
  368.    B:
  369. '
  370. '  Here we paste the highlighted bob for filled freehand 
  371. '
  372.    Paste Bob 305,36,22
  373. '
  374. '  And set up the variables again.  If you've forgotten what they are used 
  375. '  for, don't forget the Variable tables supplied with this package !
  376. '
  377.    XB=305 : YB=36 : BO=3 : T=2 : F2=2
  378. '
  379. '  Another label to show where the main body of the procedure lies.
  380. '
  381.    BEGIN:
  382. '
  383. '  Again, and you will see repeated in all of these procedures, the 'Repeat/ 
  384. '  Until' loop.  Its main purpose being to check until the mouse enters the
  385. '  drawing area or another choice from the menu bar is selected. 
  386. '
  387.    Repeat 
  388.       If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
  389.    Until Mouse Zone=0
  390.    _SCOPY
  391. '
  392. '  Another label 
  393. '
  394.    BEGIN2:
  395. '
  396. '  Initialise a 'Do/Loop' loop with the next command.
  397. '
  398.    Do 
  399. '
  400. '  Check for crosshairs, if the CROSS variable is set to one then jump to
  401. '  the CROSSHAIRS procedure. 
  402. '
  403.       If CROSS=1 Then Proc CROSSHAIRS
  404. '
  405. '  Has the user began to draw ?  Yes ?  Then make a copy of the screen with
  406. '  the _SCOPY procedure and jump to the BEGIN3 label.  
  407. '
  408.       If Mouse Click and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
  409. '
  410. '  Again, check if the mouse has left the drawing area.  If it has then end
  411. '  the procedure by jumping to the finished label, otherwise continue with 
  412. '  the next line.
  413. '
  414.       If Mouse Zone<>0 Then Goto FINISHED
  415. '
  416. '  Same as the last procedure.  Check to see if the co-ordinates have been 
  417. '  been switched on by looking at the COORDS variable.  If it is set to one
  418. '  then jump to the COORDS procedure to display them.
  419. '
  420.       If COORDS=1 Then Proc COORDS
  421. '
  422. '  The next command sends the program back up there to the 'DO' command to 
  423. '  continue the loop.
  424. '
  425.    Loop 
  426. '  Another label.
  427. '
  428.    BEGIN3:
  429. '
  430. '  And now we will set the drawing mode to normal.  This means that anything 
  431. '  the user draws will be fixed onto the display.  We do this because other  
  432. '  parts of the program like the CROSSHAIRS procedure use a drawing mode 
  433. '  called 'GR WRITING 2'.  This is a command that uses another drawing method
  434. '  whereby anything drawn once and then drawn over again will be removed.
  435. '  That's why the crosshairs dont destroy anything the user has drawn.  It 
  436. '  is also known as the Exclusive Or mode - XOR.  We set it to normal here 
  437. '  incase a procedure such as LINE has to be left early and maybe still in 
  438. '  the XOR mode, its just a safegurad. 
  439. '
  440.    Gr Writing 1
  441. '
  442. '  Now we use the next command to tell the computer only to execute the lines
  443. '  inside the 'While/Wend' loop while the left mouse key is being pressed. 
  444. '  The key is recognised by the computer as key 1. 
  445. '
  446.    While Mouse Key=1
  447. '
  448. '  Here we load the variable X and Y with the current mouse co-ordinates.
  449. '  The use of the command 'X Screen(X Mouse)' is because the actual co-ords
  450. '  of the mouse (hardware co-ordinates) are very much different from the 
  451. '  co-ordinates you see on the screen (screen co-ordinates).  So we use
  452. '  this command to make the conversion for us. 
  453. '
  454. RANGECHECK: X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  455.  If Y<11 or X>289 Then Goto RANGECHECK
  456. '  
  457. '  Next we instruct the computer to Wait 1, or 1/50th of a second
  458. '
  459.       Wait 1
  460. '
  461. '  Now we load more variables with the current mouse co-ordinates.  Again, 
  462. '  note the use of the 'X Screen(Xmouse)' commands etc.  If you are wondering
  463. '  why we have got the co-ordinates again then let me explain.  Although 
  464. '  when you use this procedure and draw freehand it seems as though you are
  465. '  just quickly plotting points on the screen it is actually drawing straight
  466. '  lines from one point to another - very quickly admittedly, but none the 
  467. '  less, they are straight lines.  We have to do it this way to keep the 
  468. '  lines continuous, and hence the reason why we need two set of variables.  
  469. '  One set (X and Y) hold the initial or starting point of the line, and the 
  470. '  other set (X1 and Y1) hold the target point of the line 
  471. '
  472.  X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
  473.  If Y1<11 or X1>290 Then Goto RANGECHECK
  474. '
  475. '  And here is the command that draws the lines between our two sets of
  476. '  variables.  Of course we have to set the ink colour as well, and this 
  477. '  is taken care of by the variable I. 
  478. '
  479.       Ink I : Draw X,Y To X1,Y1
  480. '
  481. '  Yes, we check the mouse position again to see if it has left the drawing  
  482. '  area (Zone 0).  If it has, then end this procedure by jumping the label 
  483. '  called FINISHED.
  484. '
  485.       If Mouse Zone<>0 Then Goto FINISHED
  486. '
  487. '  And update the co-ordinate display - if its turned on.
  488. '
  489.       If COORDS=1 Then Proc COORDS
  490. '
  491. '  Next we return the 'While' command with its counterpart 'Wend'
  492. '
  493.    Wend 
  494. '
  495. '  Here is another check on a variable.  This one is checking to see which 
  496. '  part of this procedure has been activated.  Remember this procedure is a
  497. '  multiple option procedure, where the options are either a normal freehand 
  498. '  line or and filled freehand shape.  We can tell what option has been
  499. '  selected by reading the variable F2TYPE, if its 0 then we should ignore 
  500. '  the next line - 0 denotes a normal line.  But if it is set to 1 then
  501. '  we should fill inside the shape the user has drawn with the command 'Paint' 
  502. '  But how do we know where to fill ?  Well, we know the last position of
  503. '  the mouse, we stored it in the variables X and Y, so a good guess would 
  504. '  be to add 2 pixels to the Y co-ordinate, and this should put us some where  
  505. '  inside the users shape.  Please note however that this isn't definate, and  
  506. '  for this to work fully we need to hope the user always finishes his shape 
  507. '  roughly at the top of the screen or else we will end up filling the whole 
  508. '  screen !
  509. '  
  510.    If F2TYPE=1 Then Paint X,Y+2
  511. '
  512. '  Now we go directly to the mid procedure label to save us going through
  513. '  the initial checks again. 
  514. '
  515.    Goto BEGIN2
  516. '
  517. '  And here again as before is the FINISHED label just before the 'End Proc' 
  518. '  command that is used in the procedure when the user has finished with this  
  519. '  tool and wished to re-select. 
  520. '
  521.    FINISHED:
  522. '
  523. '  And we terminate this procedure with the following command... 
  524. '
  525. End Proc
  526. '
  527. '  Next we come to the STRAIGHTLINE procedure.  A very simple piece of   
  528. '  program, and no multiple options.  It simply draws a line between two 
  529. '  co-ordinates. 
  530. '
  531. Procedure STRAIGHTLINE
  532. '
  533. '  The same initial checks as all the previous procedures. Remember that 
  534. '  the variable T will only be set if this procedure has been called before. 
  535. '  So we check if T doesn't equal 3, and if it doesn't we paste the  
  536. '  un-highlighted bob on the menu bar, otherwise we go to the next line. 
  537. '
  538.    If T<>3 Then Paste Bob XB,YB,BO Else Goto BEGIN
  539. '
  540. '  And paste the highlighted bob.
  541. '  
  542.    Paste Bob 292,49,27
  543. '
  544. '  Then load the variable with the positions of the newly pasted bob and 
  545. '  set the variable T to 3, to signify that this procedure has been used.
  546. '
  547.    XB=292 : YB=49 : BO=6 : T=3
  548. '
  549. '  Another label.
  550. '
  551.    BEGIN:
  552. '
  553. '  And we initialise another loop, checking to see if the user has selected
  554. '  ant other options while still on the menu bar.  The loop is terminated as 
  555. '  soon as the mouse enters the drawing area (zone 0). 
  556. '
  557.    Repeat 
  558.       If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
  559.    Until Mouse Zone=0
  560. '
  561. '  Another loop now, this time doing many things, let me explain...
  562. '
  563.    Do 
  564. '
  565. '  Here we repeatedly load the variables X and Y with the mouse co-ordinates.
  566. '  We do this now because other checks in this loop await the pressing of the
  567. '  left mouse button.  This press will signify the user wishes to draw a line
  568. '  from that point (which we have in X and Y) to another point - which we get
  569. '  later.
  570. '
  571. RANGECHECK: X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  572. If Mouse Zone<>0 and Mouse Key=1 Then Goto FINISHED
  573.  If Y<11 or X>289 Then Goto RANGECHECK
  574. '
  575. '  The next two lines, as before, check to see if either the Crosshairs or 
  576. '  co-ordinates have been activated, and if so, do a quick call to the 
  577. '  relevant procedures.
  578. '
  579.       If CROSS=1 Then Proc CROSSHAIRS
  580.       If COORDS=1 Then Proc COORDS
  581. '
  582. '  The next line checks for a left mouse button press.  If it finds what it
  583. '  is looking for i.e a value of 1, then it quickly copies the current screen
  584. '  using the _SCOPY procedure and jumps to the BEGIN2 label. 
  585. '
  586.       If Mouse Key=1 and Mouse Zone=0 Then _SCOPY : Goto BEGIN2
  587. '
  588. '  And here we check to see if the mouse has left the drawing area.  If it 
  589. '  has, then jump to the label FINISHED. 
  590. '
  591.       If Mouse Zone<>0 Then Goto FINISHED
  592. '  And complete the 'Do/Loop' loop, with the command 'Loop'
  593. '
  594.    Loop 
  595. '
  596. '  Another label!
  597. '
  598.    BEGIN2:
  599. '
  600. '  Another loop!  Only to be executed while the left mouse button is pressed.
  601. '
  602.    While Mouse Key=1
  603. '
  604. '  Check the co-ordinates variable.
  605. '
  606.       If COORDS=1 Then Proc COORDS
  607. '
  608. '  Load the variables X1 and Y1 with the current screen co-ordinates of the
  609. '  the mouse.  These will be used as a 'target' for the line drawing command.
  610. '  Remember that we stored the initial (starting) point of the drawing 
  611. '  operation in the variables X and Y. 
  612. '
  613. RANGECHECK2: X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
  614.  If Y1<11 or X1>289 Then Goto RANGECHECK2
  615. '
  616. '  Now we set the drawing mode to XOR using the following command.  This 
  617. '  allows the user to 'stretch' the line over his drawing with destroying
  618. '  any of his work.  This technique is also known as rubber banding. 
  619. '
  620.       Gr Writing 2
  621. '
  622. '  And we drawn a line in the current ink colour (I) between our co-ordinates, 
  623. '  the variables X,Y and X1,Y1.  
  624. '
  625.       Ink I : Draw X,Y To X1,Y1
  626. '
  627. '  And now we draw the exact same line again.  The reason ?  Well, as we said
  628. '  earlier, when you are using the XOR mode (GR Writing 2), anything you draw
  629. '  and then draw over again will be removed without any ill effects to things
  630. '  already there.  This is a very simplistic way of describing its effects,  
  631. '  and I suggest you try it for yourself to see the effect.  It is more than 
  632. '  useful for tasks such as these and is well worth remembering.  In fact it 
  633. '  is extensively used throughout this program.  You can see it in action
  634. '  whenever you see a stretching effect - in this procedure, and the box 
  635. '  procedure you will see it to its best effect. 
  636. '
  637.       Draw X,Y To X1,Y1
  638. '
  639. '  And now finish the loop with the following command. 
  640. '
  641.    Wend 
  642. '
  643. '  Now we are here the user has obviously released the button to draw his  
  644. '  line.  So we must set the drawing mode back to normal to fix the image on 
  645. '  the screen by using the following command.  
  646. '
  647.    Gr Writing 1
  648. '
  649. '  And then re-draw the line proper in the current ink colour.  We still have
  650. '  the old co-ordinates, so there is no need to get them again.  
  651. '
  652.    Ink I : Draw X,Y To X1,Y1
  653. '
  654. '  And now jump back to the label BEGIN to do it all again ! 
  655. '
  656.    Goto BEGIN
  657. '
  658. '  Here we set the FINISHED label for earlier parts of the program to jump 
  659. '  to should the user require another option.
  660. '
  661.    FINISHED:
  662. '
  663. '  And end the procedure!  Not to difficult eh ?  Good.
  664. '
  665. End Proc
  666. '
  667. '  NOTE,  the following procedure is incomplete and un-documented. 
  668. '
  669. Procedure F4
  670.    If T<>4 Then Paste Bob XB,YB,BO Else Goto FINISHED
  671.    Paste Bob 305,49,28
  672.    XB=305 : YB=49 : BO=7 : T=4
  673.    FINISHED:
  674.    Print "hi"
  675. End Proc
  676. '
  677. '  Now comes another multiple choice procedure.  The choices being either
  678. '  a filled or un-filled circle.  Note the name of the procedure - FCIRCLE 
  679. '  is named such for no other reason other than AMOS commands can't be 
  680. '  used as names or labels.  So we stick the letter F in front of Circle 
  681. '  to get away with it for the sake of clarity.
  682. '
  683. Procedure FCIRCLE
  684. '
  685. '  If you missed it earlier, T is a variable that tells us whether the 
  686. '  procedure has been used before.  If it doesn't equal 5 then we paste
  687. '  an inactive bob on the menu bar.
  688. '
  689.    If T<>5 Then Paste Bob XB,YB,BO
  690. '
  691. '  Please see the Variable table regarding EasyPaint for descriptions of 
  692. '  the following variables.
  693. '
  694.    If F5=1 and F5TYPE=1 Then Goto B
  695.    If F5=1 and F5TYPE=0 Then Goto A
  696.    If F5=2 and F5TYPE=0 Then Goto A
  697.    If F5=2 and F5TYPE=1 Then Goto B
  698. '
  699.    A:
  700. '
  701. '  We paste the highlighted bob for an empty circle on the menu bar. 
  702. '
  703.    Paste Bob 292,62,25
  704. '
  705. '  And as before, load the following variables with the co-ordinates at
  706. '  which these bobs will be pasted.
  707. '
  708.    XB=292 : YB=62 : BO=4 : T=5 : F5=1
  709. '
  710. '  And then jump to the label BEGIN
  711. '
  712.    Goto BEGIN : 
  713. '
  714. '  We paste the highlighted bob for a filled circle on the menu bar. 
  715. '
  716.    B:
  717.    Paste Bob 292,62,23
  718. '
  719. '  And load up the variables.  If your unsure about these, then please se
  720. '  the supplied variable table regarding the Easy Paint program. 
  721. '
  722.    XB=292 : YB=62 : BO=4 : T=5 : F5=2
  723. '
  724. '  And then jump the label BEGIN 
  725. '
  726.    BEGIN:
  727. '
  728. '  Now to initialise a 'Repeat/Until' loop with the following command. 
  729. '
  730.    Repeat 
  731. '
  732. '  Note that we are checking inside this loop to see if the user has selected
  733. '  another option while still on the menu bar.  The loop will end as soon as 
  734. '  its conditions have been met i.e. when the mouse enters the drawing area
  735. '  also known as (zone 0)
  736. '
  737.       If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
  738. '
  739. '  And here is the conditional part of the loop. 
  740. '
  741.    Until Mouse Zone=0
  742. '
  743. '  The user has entered the drawing area, so we'll copy the screen now in case 
  744. '  he draws something he doesn't want.  Then, if he presses the undo button
  745. '  we can copy an image of the screen as it was, back to the drawing area. 
  746. '
  747.    _SCOPY
  748. '
  749. '  And a label follows.
  750. '
  751.    BEGIN2:
  752. '
  753. '  Now we start off another loop.  We dont want any conditions to this one 
  754. '  because it shouldn't until a line inside jumps out.  So we use the 'Do/Loop'
  755. '  loop. 
  756. '
  757.    Do 
  758. '
  759. '  The next two lines check too see if either the co-ordinates or the  
  760. '  cross-hairs have been activated, and if they have, they jump out to the 
  761. '  relevant procedures.
  762. '
  763.       If COORDS=1 Then Proc COORDS
  764.       If CROSS=1 Then Proc CROSSHAIRS
  765. '
  766. '  Now we load the variables X and Y with the current screen co-ordinates of 
  767. '  the mouse in preparation for drawing the circle.  These variables will act
  768. '  as the centre of the eventual circle. 
  769. '
  770. RANGECHECK: X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  771.       If Mouse Zone<>0 and Mouse Key=1 Then Goto FINISHED
  772.  If Y<11 or X>288 Then Goto RANGECHECK
  773. '
  774. '  A quick check of the mouse to see if the left button has been pressed.
  775. '  If it has then we copy the screen using the _SCOPY procedure, and jump out
  776. '  of this loop to the BEGIN3 label.  Remember, we copy the screen in case 
  777. '  the user makes an error during a drawing operation and wants to undo it.
  778. '  The copied screen is held in screen 2 which we opened at the beginning of 
  779. '  this program, and is simply copied back when the undo button is pressed.
  780. '
  781.       If Mouse Key=1 and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
  782. '
  783. '  Also checking here to see if the mouse has left the drawing area, and if
  784. '  so we tell the computer to jump to the label FINISHED.
  785. '
  786.       If Mouse Zone<>0 Then Goto FINISHED
  787. '  
  788. '  And return the loop with the next command.
  789. '
  790.    Loop 
  791. '
  792. '  Here is the label that marks the start of the actual drawing part of this 
  793. '  procedure.
  794. '
  795.    BEGIN3:
  796. '
  797. '  And we check to see if the left mouse key is pressed with the next line.  
  798. '  If it is then we start to cycle through the program contained inside the
  799. '  'While/Wend' loop.  As soon as the left mouse key is released, the loop 
  800. '  will terminate. 
  801. '
  802.    While Mouse Key=1
  803. '
  804. '  Another check on the COORDS variable. 
  805. '
  806.       If COORDS=1 Then Proc COORDS
  807. '
  808. '  Here we continually load the X1 variable with the X co-ordinate of the
  809. '  the mouse. We do this because the diameter of the circle is measured by 
  810. '  calculating the distance from the initial starting point (X) and the  
  811. '  current X co-ordinate stored in X1 - the next line. 
  812. '
  813. RANGECHECK2: X1=X Screen(X Mouse)
  814.  If X1>288 Then Goto RANGECHECK2
  815. '
  816. '  And then, as before, we set the drawing mode to XOR because the user needs
  817. '  to see where to position the circle without actually drawing tens of them 
  818. '  all over his work.  The next command enables this mode. 
  819. '
  820.       Gr Writing 2
  821. '
  822. '  And here we draw the circle.  Note that X and Y variables hold the centre 
  823. '  point of the circle, and the diameter is calculated by subtracting X+1 from 
  824. '  X1.  We add the one to X because AMOS doesn't allow you to use negative   
  825. '  values when drawing circles, and if we didn't, as soon as the user started to 
  826. '  draw his circle an error would be generated due to the diameter being 
  827. '  calculated at exactly 0, or the value you would get by subtracting X1-X 
  828. '  Please also note that if your not sure of how the variables are being 
  829. '  calculated at any point in the program, try using the command 'Follow' at 
  830. '  certain key places.  More information on how to use this command for your 
  831. '  benefit can be found in the variables table for Easy Paint. 
  832. '
  833.       Ink I : Circle X,Y,X1-X+1
  834. '
  835. '  Now we re-draw an exact copy of the previous circle.  Remember, because we
  836. '  are in XOR mode, this circle will remove the last one from the display
  837. '  without drawing over anything else, thus giving the illusion of being able  
  838. '  to stretch the circle.
  839. '
  840.       Circle X,Y,X1-X+1
  841. '
  842. '  A quick check on the mouse to make sure the mouse is still on the drawing 
  843. '  area.  If it isn't then we jump to the FINISHED label to end this 
  844. '  procedure.
  845. '
  846.       If Mouse Zone<>0 Then Goto FINISHED
  847. '
  848. '  And complete the 'While/Wend' loop with the 'Wend' command. 
  849. '
  850.    Wend 
  851. '
  852. '  Now we set the ink colour.  Switch the drawing mode back to normal and
  853. '  draw in the final circle. 
  854. '
  855.    Ink I : Gr Writing 1 : Circle X,Y,X1-X+1
  856. '
  857. '  The variable F5TYPE tells us which options in this procedure have been  
  858. '  selected.  If the variable is set to 1, we know that the filled circle  
  859. '  option is in use.  So we check, and if it is we fill the circle with
  860. '  the paint command.  Remember that we still have the centre point of the 
  861. '  circle stored in the variables X and Y, so we just use these in the paint 
  862. '  command so it knows where to start filling! 
  863. '
  864.    If F5TYPE=1 Then Paint X,Y
  865. '
  866. '  And now just to jump back to the BEGIN2 label to do it all again. Phew! 
  867. '
  868.    Goto BEGIN2
  869. '
  870. '  Here is the finished label again, just before the 'End Proc' command so 
  871. '  any part of the above can jump here to finish.
  872. '
  873.    FINISHED:
  874. '
  875. '  And finally,  the end of the FCIRCLE procedure. 
  876. '
  877. End Proc
  878. '
  879. '  Yet another multiple choice procedure!  Not to worry, only two more after 
  880. '  this one. Again, the name has an F before it simply because it's an AMOS  
  881. '  command, that's all.  The options, as before, are for either a filled or
  882. '  un-filled box.
  883. '
  884. Procedure FBOX
  885.       X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  886. '
  887. '  Again, as in other procedures selectable from the menu bar, if this 
  888. '  procedure is different from the last one called we need to paste a normal 
  889. '  bob on the menu bar to show the user that the last option selected is no
  890. '  longer in use.  This is done by checking the variable T.  If this 
  891. '  procedure has been by this point before then it will have set the 
  892. '  variable to its procedure number - i.e. 6.  So if we check the variable 
  893. '  T and find it doesn't equal 6 then we need to paste a bob over the last 
  894. '  one that was highlighted.  How ?  Well, the last procedure that was in  
  895. '  use will have set the variables XB,YB and BO with its co-ordinates and bob
  896. '  number, so all we now do is use these to paste an un-highlighted bob at 
  897. '  these positions!
  898. '
  899.    If T<>6 Then Paste Bob XB,YB,BO
  900. '
  901. '  Please see the supplied variables table regarding Easy Paint for details
  902. '  on the following variables and there functions. 
  903. '
  904.    If F6=1 and F6TYPE=1 Then Goto B
  905.    If F6=1 and F6TYPE=0 Then Goto A
  906.    If F6=2 and F6TYPE=0 Then Goto A
  907.    If F6=2 and F6TYPE=1 Then Goto B
  908.    A:
  909. '
  910. '  Here we are pasting a highlighted bob for the unfilled box on the menu bar
  911. '
  912.    Paste Bob 305,62,26
  913. '
  914. '  And here, as mentioned above, we load some variables with the co-ordinates  
  915. '  of the bob, and load the variable BO with the bob number for the normal,
  916. '  un-highlighted box bob.  This is so that when we leave this procedure, the
  917. '  next one can simply read these variables and paste over our highlighted one.
  918. '  Simple eh ?  We also set the variable T to this procedures number - 6 - to  
  919. '  also make sure that if this procedure is reselected for any reason, we dont 
  920. '  want to paste an un-highlighted bob on the menu bar while this is still in
  921. '  use.  Also see above for the check on the T variable.   
  922. '
  923.    XB=305 : YB=62 : BO=5 : T=6 : F6=1
  924. '
  925.    Goto BEGIN
  926.    B:
  927. '
  928. '  Here we paste the highlighted bob for the filled box on the menu bar
  929. '
  930.    Paste Bob 305,62,24
  931. '
  932. '  And again load the variables for our bob position and number in preperation 
  933. '  for when this procedure is left.  We also set the variable T in here as 
  934. '  well because the previous section will obviously get skipped if the user  
  935. '  selects the filled box option.
  936. '
  937.    XB=305 : YB=62 : BO=5 : T=6 : F6=2
  938. '
  939. '  Next comes a label to signify the main body of this procedure.
  940. '
  941.    BEGIN:
  942. '
  943. '  We initiate a loop until the mouse enters the drawing area, while always
  944. '  checking to see if the left mouse key is being pressed while the mouse
  945. '  is outside the drawing area.
  946. '
  947.    Repeat 
  948.       If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
  949. '
  950. '  The condition of the 'Repeat/Until' loop is to repeat until the mouse 
  951. '  enters the drawing area.
  952. '
  953.    Until Mouse Zone=0
  954. '
  955. '  Now we set up another conditional loop that waits until a mouse key is
  956. '  pressed.  The user will be positioning the mouse at this point, in  
  957. '  preparation for drawing a box.
  958. '
  959.    While Mouse Key=0
  960. '
  961. '  As before, we check for both the crosshairs and co-ordinates, and if they 
  962. '  have been selected, if either variable holds a value of 1, then we do a 
  963. '  jump to the relevant procedures.
  964. '
  965.       If COORDS=1 Then Proc COORDS
  966.       If CROSS=1 Then Proc CROSSHAIRS
  967. '
  968. '  We also make a provision in here, rather than outside the loop, to check  
  969. '  if the left mouse key is pressed in the drawing area.  If it is, then 
  970. '  we copy the screen using the _SCOPY procedure and leave the loop by 
  971. '  jumping to the BEGIN3 label 
  972. '  
  973.       If Mouse Key=1 and Mouse Zone=0 Then Goto BEGIN3
  974. '
  975. '  We must also check to see if the mouse has left the drawing area, and if
  976. '  so, then we must end this procedure by jumping to the FINISHED label. The   
  977. '  chance existing that the user wished to select another option or ink colour 
  978. '  from the menu bar.
  979. '
  980.       If Mouse Zone<>0 Then Goto FINISHED
  981. '
  982. '  The next line loads the variables X and Y with the current mouse co-
  983. '  ordinates as long as the loop is cycling.  When we leave the loop this
  984. '  will give us the top left point of the box. 
  985. '
  986.       X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  987. '
  988. '  Now we return the loop with the 'Wend' command
  989. '
  990.    Wend 
  991. _SCOPY
  992. '
  993. '  Another label.
  994. '
  995.    BEGIN3:
  996. '
  997. '  And another loop, this time containing the program that will generate   
  998. '  the stretching or rubber banding effect while the left mouse key is being 
  999. '  pressed.
  1000. '
  1001.    While Mouse Key=1
  1002. '
  1003. '  We set the drawing mode to XOR so the stretching box will not destroy any 
  1004. '  existing drawings.
  1005. '
  1006.       Gr Writing 2
  1007. '
  1008. '  And wait 1/50th of a second, purely to slow down the screen update to 
  1009. '  help get rid of any flicker will be box is being stretched. 
  1010. '
  1011.       Wait 1
  1012. '
  1013. '  Now we load the variables X1 and Y1 with the current screen co-ordintes 
  1014. '  of the mouse.  The will be used shortly as target points for the box to 
  1015. '  be drawn to.
  1016. '
  1017.       X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
  1018. '
  1019. '  And now we set the ink colour to the variable I and draw the box from our 
  1020. '  old X and Y variables to the current X1 and Y1 variables. 
  1021. '
  1022.       Ink I : Box X,Y To X1,Y1 : Wait Vbl 
  1023. '
  1024. '  As with all rubber banding, we now need to draw an exact image of the last
  1025. '  box over the top of the old one to remove it from the drawing area. 
  1026. '
  1027.       Box X,Y To X1,Y1
  1028. '
  1029. '  And return the loop with a 'Wend' command.
  1030. '
  1031.    Wend 
  1032. '
  1033. '  The next line sets the drawing mode back to normal, ready to draw the final 
  1034. '  box on the screen.
  1035. '
  1036.    Gr Writing 1
  1037. '
  1038. '  Which is accomplished by drawing a box of the current ink colour at the 
  1039. '  last co-ordinates obtained in the above program.
  1040. '
  1041.    Ink I : Box X,Y To X1,Y1
  1042. '
  1043. '  The variable F6TYPE holds a number which tells us which of the multiple 
  1044. '  choices this procedure possesses has been selected. If this variable holds
  1045. '  a value of 1, we know the user wants the box to be filled after it is 
  1046. '  drawn.  Note that we have used this method to best show the way options 
  1047. '  can be read and acted on.  It would be perfectly acceptable to check for
  1048. '  the filled box option above and use the 'Bar' command to draw a filled box
  1049. '  'real time'.
  1050. '
  1051.    If F6TYPE=1 and X1<X Then Bar X1,Y1 To X,Y
  1052.    If F6TYPE=1 and X1>X Then Bar X,Y To X1,Y1
  1053. '
  1054. '  Here we jump back into this procedure to do it again. 
  1055. '
  1056.    Goto BEGIN
  1057. '
  1058. '  And the next label is used just before the 'End Proc' command to allow  
  1059. '  earlier parts of this procedure to exit immediately.
  1060. '
  1061.    FINISHED:
  1062. '
  1063. '  The end of this procedure.
  1064. '
  1065. End Proc
  1066. '
  1067. '  Another multiple choice procedure using exactly the same format as the
  1068. '  FCIRCLE procedure for filled and unfilled ellipses.  In fact, the only
  1069. '  difference is the use of the 'Ellipse' command intead of 'Circle', but I  
  1070. '  shant skimp! And I'll detail just whats happening.
  1071. '
  1072. Procedure FELLIPSE
  1073. '
  1074. '  This next line checks the T variable to see if this procedure has just
  1075. '  been called.  If it hasn't then the T variable will have been set by  
  1076. '  another procedure, as well as the variables XB,YB and BO.  Should T not 
  1077. '  equal 7 then we paste a bob at the preset co-ordinates stored in these  
  1078. '  variables.
  1079. '
  1080.    If T<>7 Then Paste Bob XB,YB,BO
  1081. '
  1082. '  Please see the supplied variables list regarding the uses of the following
  1083. '  variables.  The lines just determine what choices have been selected and
  1084. '  then jump to the relevant label to past the correct highlighted bob on  
  1085. '  the menu bar. 
  1086. '
  1087.    If F7=1 and F7TYPE=1 Then Goto B
  1088.    If F7=1 and F7TYPE=0 Then Goto A
  1089.    If F7=2 and F7TYPE=0 Then Goto A
  1090.    If F7=2 and F7TYPE=1 Then Goto B
  1091. '
  1092.    A:
  1093. '  Here we paste the bob for the unfilled ellipse on the menu bar. 
  1094. '
  1095.    Paste Bob 292,75,39
  1096. '  
  1097. '  And then set the variables used by this and other procedures to switch  
  1098. '  off the selection on the menu bar by pasting an unhighlted ellipse, also
  1099. '  known as bob 16.
  1100. '
  1101.    XB=292 : YB=75 : BO=16 : T=7 : F7=1
  1102. '  
  1103. '  Then we jump to the begin label.
  1104. '
  1105.    Goto BEGIN : 
  1106. '
  1107.    B:
  1108. '
  1109. '  He we paste the bob for the filled ellipse on the menu bar. 
  1110. '
  1111.    Paste Bob 292,75,38
  1112. '
  1113. '  And then set the variables used by this and other procedures to switch  
  1114. '  off the selection on the menu bar by pasting an unhighlted ellipse, also
  1115. '  known as bob 16.
  1116. '
  1117.    XB=292 : YB=75 : BO=16 : T=7 : F7=2
  1118. '
  1119.    BEGIN:
  1120. '
  1121. '  Now we initialise a conditional loop that will wait for the mouse to enter
  1122. '  the drawing area. 
  1123. '
  1124.    Repeat 
  1125. '
  1126. '  But inside we also check to see if the left mouse key has been pressed
  1127. '  while the mouse is off the drawing area (zone 0).  If it has then we must 
  1128. '  terminate this procedure by jumping to the label FINISHED so that the 
  1129. '  user can select another option. 
  1130. '
  1131.       If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED : 
  1132. '
  1133. '  And complete the 'Repeat/Until' with the following command and conditions.
  1134. '  So this will return the computer back to the 'Repeat' command until the 
  1135. '  mouse enters the drawing area (zone 0)
  1136. '
  1137.    Until Mouse Zone=0
  1138. '
  1139. '  Quickly copy the screen now by calling the _SCOPY procedure.
  1140. '
  1141.    _SCOPY
  1142. '
  1143. '  And label the start of the procedure proper by the following ...
  1144. '
  1145.    BEGIN2:
  1146. '
  1147. '  Initiate another conditional loop now.  We want this is to loop until the 
  1148. '  mouse key is pressed. 
  1149. '
  1150.    While Mouse Key=0
  1151. '
  1152. '  You should be better either pretty familiar with the procedures layout by 
  1153. '  now or very, very annoyed with the repetitiveness.  However !  The next 
  1154. '  two lines check to see whether the crosshairs or co-ordinates have been 
  1155. '  activated by checking their associated variables.  If either is positive (
  1156. '  has a value of 1) then we do a quick jump to the relevant procedure.
  1157. '
  1158.       If COORDS=1 Then Proc COORDS
  1159.       If CROSS=1 Then Proc CROSSHAIRS
  1160. '
  1161. '  Then load the current mouse co-ordinates into the variables X and Y.  We
  1162. '  do this in here so we have a continuous stream of data going into these 
  1163. '  variables from the mouse position.  The X and Y variables will eventually 
  1164. '  hold the centre point of our ellipse. 
  1165. '
  1166.       X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  1167. '
  1168. '  A check to see if the user has started drawing.  If the left mouse key
  1169. '  has been pressed and the mouse is in the drawing area then we copy the
  1170. '  screen and jump to the BEGIN3 label, ready to start drawing.  
  1171. '
  1172.       If Mouse Key=1 and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
  1173. '
  1174. '  If the mouse leaves the drawing area (zone 0) we need to end this procedure 
  1175. '  and return to check the zones of the menu bar.  We do this with the next
  1176. '  line that will jump to the label FINISHED should the conditions be met. 
  1177. '
  1178.       If Mouse Zone<>0 Then Goto FINISHED
  1179. '
  1180. '  And finish the loop with the next command.
  1181. '
  1182.    Wend 
  1183.    Wait 1
  1184.    BEGIN3:
  1185.    While Mouse Key=1
  1186.       If COORDS=1 Then Proc COORDS
  1187.       X1=X Screen(X Mouse)
  1188.       Y1=Y Screen(Y Mouse)
  1189.       Gr Writing 2
  1190.       Ink I : Ellipse X,Y,X1-X+1,Y1-Y+1
  1191.       Ellipse X,Y,X1-X+1,Y1-Y+1
  1192.    Wend 
  1193.    Gr Writing 1 : Ink I : Ellipse X,Y,X1-X+1,Y1-Y+1
  1194.    If F7TYPE=1 Then Paint X,Y
  1195.    Goto BEGIN2
  1196.    FINISHED:
  1197. End Proc
  1198. '
  1199. '  Yes, this is the last of the multiple option procedures.  This next one 
  1200. '  is used to draw polygons, with the end result having the option of being
  1201. '  either filled or un-filled. 
  1202. '
  1203. Procedure FPOLYGON
  1204. '
  1205. '  The following lines share the same format as all the others previously. 
  1206. '  We check the T variable first to see if this procedure was the last one 
  1207. '  called, and if not, we use the variables set in the previous procedure
  1208. '  to paste an un-highlighted bob on the menu bar. 
  1209. '
  1210.    If T<>8 Then Paste Bob XB,YB,BO
  1211. '
  1212. '  Look at the variable table to find the meanings of the following variables. 
  1213. '  Depending on their contents we know which part of this procedure to jump
  1214. '  to. 
  1215. '
  1216.    If F8=1 and F8TYPE=1 Then Goto B
  1217.    If F8=1 and F8TYPE=0 Then Goto A
  1218.    If F8=2 and F8TYPE=0 Then Goto A
  1219.    If F8=2 and F8TYPE=1 Then Goto B
  1220. '
  1221. '
  1222.    A:
  1223. '
  1224. '  Here we paste the highlighted bob for the un-filled polygon tool on the 
  1225. '  menu. 
  1226. '
  1227.    Paste Bob 305,75,30
  1228. '
  1229. '  And then set the following variables so any other procedure like this one 
  1230. '  knows where to paste the de-selected bob on the menu bar - bob number (9).  
  1231. '
  1232.    XB=305 : YB=75 : BO=9 : T=8 : F8=1
  1233. '
  1234. '  Now we jump to the BEGIN label to enter the procedure proper. 
  1235. '
  1236.    Goto BEGIN
  1237. '
  1238.    B:
  1239. '
  1240. '  Here we paste the highlighted bob for the filled polygon tool on the menu 
  1241. '  bar.
  1242. '
  1243.    Paste Bob 305,75,31
  1244. '
  1245. '  And then set the following variables so any other procedure like this one 
  1246. '  knows where to paste the de-selected bob on the menu bar - bob number (9).  
  1247. '
  1248.    XB=305 : YB=75 : BO=9 : T=8 : F8=2
  1249. '
  1250. '  Next comes the label that marks the actual or proper part of this 
  1251. '  procedure.
  1252. '
  1253.    BEGIN:
  1254. '
  1255. '  Now we initialise a conditional loop that will wait for the mouse to
  1256. '  enter the drawing area, otherwise known to us and the computer and zone 0 
  1257. '
  1258.    Repeat 
  1259. '
  1260. '  All the while this loop is cycling we check here to see if the left mouse 
  1261. '  key is pressed while the mouse is out of the drawing area, this is so any 
  1262. '  other option can be selected. If we find that this action has been met  
  1263. '  then we must leave this procedure by jumping to the FINISHED label. 
  1264. '
  1265.       If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
  1266. '
  1267. '  And complete the loop with our conditions.  This will now cycle until the 
  1268. '  conditions are met ...
  1269. '
  1270.    Until Mouse Zone=0
  1271. '
  1272. '  Upon which we jump out to this next line.  Simply a label.
  1273. '
  1274.    BEGIN2:
  1275. '
  1276. '  Initialise another loop now.
  1277. '
  1278.    Repeat 
  1279. '
  1280. '  Same as before, the next lines check to see if either the cross-hairs 
  1281. '  or co-ordinates have been selected, and if either variable holds a value
  1282. '  of 1 then we jump to the relevant procedures. 
  1283. '
  1284.       If COORDS=1 Then Proc COORDS
  1285.       If CROSS=1 Then Proc CROSSHAIRS
  1286. '
  1287. '  The next two lines load the variables X, Y, X1 and Y1 with the current
  1288. '  x and y co-ordinates of the mouse.  I load all the variables here so as 
  1289. '  to give the procedure a full set of points to draw from initially.  If
  1290. '  I didn't then as soon as the mouse key was pressed, a line would be drawn 
  1291. '  from the top left of the screen because there was no start point.  This 
  1292. '  is so as to 'anchor' the start point when the left button is pressed. 
  1293. '
  1294.       X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  1295.       X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
  1296. '
  1297. '  Checking again to see if the mouse has left the drawing area, and if it 
  1298. '  has then we need to end the procedure by jumping to the finished label. 
  1299. '
  1300.       If Mouse Zone<>0 Then Goto FINISHED
  1301. '
  1302. '  And define the conditions of this loop with the following line.  We want  
  1303. '  the above loop to cycle until the mouse key is pressed. 
  1304. '
  1305.    Until Mouse Key=1
  1306. '
  1307. '  A very short wait of a 1/50th of a second now, just to give the computer
  1308. '  a bit of breathing space. 
  1309. '
  1310.    Wait 1
  1311. '
  1312. '  And now we label the drawing part of this procedure.
  1313. '
  1314.    BEGIN3:
  1315. '
  1316. '  We use the next loop to tell the computer to cycle through the contents 
  1317. '  of the loop until the mouse key is press.  We have already 'anchored' the 
  1318. '  starting point of our polygon so now we need to 'rubber band' the line
  1319. '  until the user sees it how he wants it. 
  1320. '
  1321.    While Mouse Key=0
  1322. '
  1323. '  Yet again we check the cross-hairs and co-ordinates, if either have a 
  1324. '  value of 1, then we quickly jump to the relevant procedures.
  1325. '
  1326.       If COORDS=1 Then Proc COORDS
  1327.       If CROSS=1 Then Proc CROSSHAIRS
  1328. '
  1329. '  The next line sets up the XOR drawing mode so can give the illusion of
  1330. '  stretching (rubber banding).
  1331. '
  1332.       Gr Writing 2
  1333. '
  1334. '  And re-load the X1 and Y1 variable with the new target location of the
  1335. '  mouse.  These hold the point at which the line will be drawn to.
  1336. '
  1337.       X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
  1338. '
  1339. '  Next we set the ink colour the current value stored in I, and then draw 
  1340. '  the actual line between X and Y (the 'anchored' points) and X1 and Y1, the
  1341. '  current co-ordinates of the mouse.
  1342. '
  1343.       Ink I : Draw X,Y To X1,Y1
  1344. '
  1345. '  We now wait another 1/50th of a second to ease up on the flickering of
  1346. '  the display.
  1347. '
  1348.       Wait 1
  1349. '
  1350. '  And then draw an exact duplicate of the last line to remove it from the 
  1351. '  display.  Remember, anything drawn in XOR mode and then drawn over will be
  1352. '  removed without destroying any graphics underneath. 
  1353. '
  1354.       Draw X,Y To X1,Y1
  1355. '
  1356. '  Next is a check to see if either the mouse has left the drawing area or 
  1357. '  the right mouse key has been pressed.  We give the option for the right 
  1358. '  mouse button here to avoid having to leave the drawing area just to finish
  1359. '  drawing a polygon.  And of course, should the mouse leave the drawing area
  1360. '  then we must end this procedure by jumping to the FINISHED label. 
  1361. '
  1362.       If Mouse Key=2 or Mouse Zone<>0 Then Goto FINISHED
  1363. '
  1364. '  And return the loop with the next command.
  1365. '
  1366.    Wend 
  1367. '
  1368. '  So we are now at the point whereby the user has pressed the mouse key.
  1369. '  We know that this means he wishes to fix the last line onto his display 
  1370. '  so we revert back to the normal drawing mode with the next command, ready 
  1371. '  to draw in the line with ...
  1372. '
  1373.    Gr Writing 1
  1374. '
  1375. '  ... this next line, first setting the ink colour to the current value.  
  1376. '
  1377.    Ink I : Draw X,Y To X1,Y1
  1378. '
  1379. '  Now as we are drawing a polygon, the last point in this line becomes the
  1380. '  the start point of the next.  So we load the X and Y variables with these 
  1381. '  values held in X1 and Y1. 
  1382. '
  1383.    X=X1 : Y=Y1
  1384. '
  1385. '  And jump to the BEGIN3 label to begin stretching the next part of this
  1386. '  polygon.
  1387. '
  1388.    Goto BEGIN3
  1389. '
  1390. '  As with every other procedure in this program, we place our FINISHED label
  1391. '  just before the End Proc command in case any part of the procedure needs
  1392. '  to end immediately, e.g if the mouse leaves the drawing area to select  
  1393. '  another option. 
  1394. '
  1395.    FINISHED:
  1396. '
  1397. '  The end of this procedure.
  1398. '
  1399. End Proc
  1400. '
  1401. '  Phew, I am almost as relieved to be documenting this next procedure as
  1402. '  you will be to be reading it.  Only thirteen lines long!  But then
  1403. '  again, all it does it set the cross-hairs variable to on or off.
  1404. '
  1405. Procedure FCROSS
  1406. '
  1407. '  Here we check to see what state this procedure is in.  We know if it is 
  1408. '  currently active by reading the F9 variable.  If the value of F9 is 1 
  1409. '  then we know that the cross-hairs are activated, if not then this line
  1410. '  is ignored. 
  1411. '
  1412.    If F9=1 Then Goto B
  1413. '
  1414. '  A simple label next.
  1415. '
  1416.    A:
  1417. '  
  1418. '  Now we paste the highlighted bob on the menu bar to show that the cross-
  1419. '  hairs are activated.
  1420. '
  1421.    Paste Bob 292,88,32
  1422. '
  1423. '  Then comes the setting of the F9 variable to let the computer know that 
  1424. '  the cross-hairs have been switched on.
  1425. '
  1426.    F9=1
  1427. '
  1428. '  And set the CROSS variable to let the other procedures know whether or
  1429. '  not to call the cross-hairs procedure (CROSSHAIRS)
  1430. '
  1431.    CROSS=1
  1432. '
  1433. '  Then we jump out of this procedure because that's all there is to it! 
  1434. '
  1435.    Goto FINISHED
  1436. '
  1437. '  The other part of this procedure is to ... switch off the crosshairs, so  
  1438. '  we start with a label.
  1439. '
  1440.    B:
  1441. '
  1442. '  Next we set the CROSS variable to 0, just so the other procedures know not
  1443. '  to call the cross-hairs procedure.
  1444. '
  1445.    CROSS=0
  1446. '
  1447. '  And paste the un-highlighted bob on the menu bar with the next line.
  1448. '
  1449.    Paste Bob 292,88,10
  1450. '
  1451. '  Then we set the F9 variable to 0, to let this procedure know that the 
  1452. '  user has cancelled the cross-hairs.  Remember that this variable is the 
  1453. '  first one checked by this procedure.
  1454. '
  1455.    F9=0
  1456. '
  1457. '  And we are finished, so we label the end with the next line.
  1458. '
  1459.    FINISHED:
  1460. '
  1461. '  And end the procedure with the next command.
  1462. '
  1463. End Proc
  1464. '
  1465. '  NOTE, the next procedure is unfinished and un-documented. 
  1466. '
  1467. Procedure F10
  1468.    If T<>10 Then Paste Bob XB,YB,BO Else Goto FINISHED
  1469.    Paste Bob 305,88,33
  1470.    XB=305 : YB=88 : BO=11 : T=10
  1471.    FINISHED:
  1472. End Proc
  1473. '  
  1474. '  The next procedure is another very simple piece of program that we use
  1475. '  to fill in any shapes with the current ink colour.  Again, this one is
  1476. '  really quite short. 
  1477. '
  1478. Procedure FFILL
  1479. '
  1480. '  We start again by checking the T variable to see if this procedure has
  1481. '  been called last.  If the T variable doesn't equal 11 (this procedures
  1482. '  number) then we can use the variables XB,YB and BO to paste an un-high
  1483. '  lighted bob of the last called procedure on to the menu bar.
  1484. '
  1485.    If T<>11 Then Paste Bob XB,YB,BO Else Goto BEGIN
  1486. '
  1487. '  Otherwise we paste the highlighted bob for this procedure on the menu 
  1488. '  bar ... 
  1489. '
  1490.    Paste Bob 292,101,41
  1491. '
  1492. '  And load up the next variables with its counterpart, the un-highlighted 
  1493. '  bob and co-ordinates, so any other procedure knows where to paste it. 
  1494. '
  1495.    XB=292 : YB=101 : BO=18 : T=11
  1496. '
  1497. '  The following line is simply a label to show the actual working part of 
  1498. '  this procedure. 
  1499. '
  1500.    BEGIN:
  1501. '
  1502. '  A quick loop now to wait until the mouse enters the drawing area from 
  1503. '  the menu bar.  Inside the loop we will also check to see if the user has
  1504. '  made another selection to cancel this one by checking to see if the left
  1505. '  mouse key has been pressed while the mouse is not on the drawing area.
  1506. '  If it has then we must end this procedure by jumping to the FINISHED label
  1507. '
  1508.    Repeat 
  1509.       If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
  1510.    Until Mouse Zone=0
  1511. '
  1512. '  A quick copy of the screen would be helpful now in case the user happens
  1513. '  to fill the wrong part of his picture.  The undo feature will make use of 
  1514. '  this by copying the image we are about to copy back to the drawing area 
  1515. '
  1516.    _SCOPY
  1517. '
  1518. '  And now we come the final part of this procedure, labeled with the next 
  1519. '  line. 
  1520. '
  1521.    BEGIN2:
  1522. '
  1523. '  No fancy conditional loops here, just a simple 'Do/Loop' to keep cycling  
  1524. '  its contents. 
  1525. '
  1526.    Do 
  1527. '
  1528. '  Check the COORDS variable for a value of 1, and if we find it we want to
  1529. '  display the co-ordinates on screen by calling the COORDS procedure. 
  1530. '
  1531.       If COORDS=1 Then Proc COORDS
  1532. '
  1533. '  This next line is waiting for a mouse key press, any key, while the mouse 
  1534. '  pointer is in the drawing area.  If this happens then we make a copy of 
  1535. '  the screen (yes, for the undo feature!) then jump to the BEGIN3 label.
  1536. '
  1537.       If Mouse Click and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
  1538. '
  1539. '  Because this is a closed loop that will loop indefinately, we need some 
  1540. '  way of getting out of this procedure.  The next line waits for the mouse
  1541. '  to leave the drawing area and then jumps to the label FINISHED, which as
  1542. '  you must know by now, is placed before every 'End Proc' command.
  1543. '
  1544.       If Mouse Zone<>0 Then Goto FINISHED
  1545. '
  1546. '  Then return the loop
  1547. '
  1548.    Loop 
  1549. '
  1550. '  We label the next line such so the above loop can jump here is the user 
  1551. '  presses a mouse key. i.e. when he wants to fill a shape.
  1552. '
  1553.    BEGIN3:
  1554. '
  1555. '  We take the precaution here of setting the fill pattern with the current
  1556. '  value held in the variable PATTERN.  It saves us wasting any more lines on  
  1557. '  something so trivial.  Next comes the current ink colour held in the  
  1558. '  variable I, and finally we use the command 'Paint' to fill from the current 
  1559. '  mouse position in screen co-ordinates.  If your unsure about screen co-ords 
  1560. '  and their uses then please read the notes that accompany this program!
  1561. '
  1562.    Set Pattern(PATTERN) : Ink I : Paint X Screen(X Mouse),Y Screen(Y Mouse) : Goto BEGIN2
  1563. '
  1564. '  The FINISHED label used to mark the end of the procedure. 
  1565. '
  1566.    FINISHED:
  1567. '
  1568. '  And the command to end this current mother ...
  1569. '
  1570. End Proc
  1571. '
  1572. '  Okay Program Pickers,  this next procedure is starting to move toward 
  1573. '  the hazy depths again but I'll try my darndest to keep it simple.  So 
  1574. '  please forgive the heavy documentation.  This procedure is responsible
  1575. '  for cutting and pasting flipped and not-flipped brushes.  So stick with 
  1576. '  me on this one, and it may help to know that some of the program lines
  1577. '  are a little larger than the screen display.  Lets GO !!  
  1578. '
  1579. Procedure FBRUSHCUTTER
  1580. '
  1581. '  First things first, and the next line checks the T variable for a value of
  1582. '  12 and if it doesn't find it pastes the un-highlighted bob for the last 
  1583. '  procedure the user used by reading the variables XB,YB and BO.  If the  
  1584. '  value equals 12 then we know the last procedure in use was this one, so we  
  1585. '  skip this bit by jumping to BEGIN label.
  1586. '
  1587.    If T<>12 Then Paste Bob XB,YB,BO Else Goto BEGIN
  1588. '
  1589. '  Next we paste the highlighted bob for this procedure on the menu bar... 
  1590. '
  1591.    Paste Bob 305,101,29
  1592. '
  1593. '  And load the following variables with the co-ordinates XB and YB.  BO will
  1594. '  hold the bob number for the un-highlighted bob of this procedure, and T is
  1595. '  the number of the procedure, same as was checked above. 
  1596. '
  1597.    XB=305 : YB=101 : BO=8 : T=12
  1598. '
  1599. '  And label the begin with, funnily enough, BEGIN 
  1600. '
  1601.    BEGIN:
  1602. '
  1603. '  Then we check with the next line for the mouse to leave the menu bar and
  1604. '  enter the drawing area (zone 0).  If the mouse key is pressed while the   
  1605. '  mouse is not on the drawing area then we should end the procedure by  
  1606. '  jumping to the end of this procedure labeled by the FINISHED label. 
  1607. '
  1608.    Repeat 
  1609.       If Mouse Zone<>0 and Mouse Key=1 Then Goto FINISHED
  1610. '
  1611. '  And of course, we must give the loop our conditions with the next line. 
  1612. '
  1613.    Until Mouse Zone=0
  1614. '
  1615. '  Now we move on, continually cycling through this next loop while the user 
  1616. '  is not pressing any buttons on the mouse. thus we use the 'While/Wend'
  1617. '  loop. 
  1618. '
  1619.    While Mouse Key=0
  1620. '
  1621. '  Check next the COORDS variable for a value of one (on) and if we find it
  1622. '  we display the current co-ordinates of the mouse by jumping to the COORDS 
  1623. '  procedure.
  1624. '
  1625.       If COORDS=1 Then Proc COORDS
  1626. '
  1627. '  Next we load the variables X and Y with current screen co-ordinates of the
  1628. '  mouse.  A description of screen and hardware co-ordinates can be found in 
  1629. '  notes relating to this program. 
  1630. '
  1631.       X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  1632. '
  1633. '  And if the mouse leaves the drawing area - if it leaves zone 0, then we 
  1634. '  must end by jumping to the FINISHED label.
  1635. '
  1636.       If Mouse Zone<>0 Then Goto FINISHED
  1637. '
  1638. '  And return the loop with the next command ... 
  1639. '
  1640.    Wend 
  1641. '
  1642. '  Next we initialise another loop that will logically continue from the 
  1643. '  previous loop by checking for the left mouse key to be pressed. 
  1644. '
  1645.    While Mouse Key=1
  1646. '
  1647. '  If the key is pressed then we end up inside this loop to execute the
  1648. '  following lines.  The first one of which being a check on the COORDS  
  1649. '  variable for a value of 1.  If we find that the condition has been met
  1650. '  then we know the user has requested earlier that he wants the co-ordinates
  1651. '  to be displayed, so we jump to the co-ordinates procedure (COORDS)
  1652. '
  1653.       If COORDS=1 Then Proc COORDS
  1654. '
  1655. '  Again, if the mouse leaves the drawing area we terminate this procedure 
  1656. '  so we can check for an alternate selection from the menu bar.  We do this 
  1657. '  by jumping to the FINISHED label. 
  1658. '
  1659.       If Mouse Zone<>0 Then Goto FINISHED
  1660. '
  1661. '  Now we set up the XOR drawing mode as described in earlier procedure.  This 
  1662. '  is so we can display a stretchable box that will cut out the correct brush. 
  1663. '
  1664.       Gr Writing 2
  1665. '
  1666. '  And wait 1/50th second to steady the display - yes, a Wait VBL will do  
  1667. '  exactly the same, but I use this line for the sake of clarity.
  1668. '
  1669.       Wait 1
  1670. '
  1671. '  Now we load the variables X1 and Y1 with the new co-ords of the mouse.  
  1672. '  These hold the values that will be used to draw the box to, remember the  
  1673. '  last loop stored the start points of our box in the variables X and Y.
  1674. '
  1675.       X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
  1676. '
  1677. '  And then we set the ink colour to the value stored in the variable I.  Now
  1678. '  comes the actual drawing of the box between our values stored in the
  1679. '  variables X, Y, X1 and Y1.
  1680. '
  1681.       Ink I : Box X,Y To X1,Y1 : Wait 1
  1682. '
  1683. '  Remember that we are now in XOR drawing mode, so anything we redraw will
  1684. '  be removed from the display without damaging any existing graphics.  This 
  1685. '  is what we do next - draw the exact same box as the last line.
  1686. '
  1687.       Box X,Y To X1,Y1
  1688. '
  1689. '  And return the loop with the next command.  Do please remember that the 
  1690. '  above will only be executed while the mouse key is being pressed ...
  1691. '
  1692.    Wend 
  1693. '
  1694. '  Once it is released we need to set the graphics mode back to normal with  
  1695. '  the next line.
  1696. '
  1697.    Gr Writing 1 : Wait 2
  1698. '
  1699. '  Now comes a very simple part of this procedure.  When we loaded the X and 
  1700. '  Y variables with our start point, those values remain fixed.  AMOS will 
  1701. '  not allow you to use negative values when grabbing a bob, it will halt the  
  1702. '  program and generate an error.  By negative values I mean, if the X1  
  1703. '  variable becomes less than the starting point - X.  We can get around this
  1704. '  by checking these variables ourselves before we get the bob, or brush as
  1705. '  art programs call them, and if X1 is less than X we simply swap the 
  1706. '  contents, the result being exactly the same.  The method is already taken 
  1707. '  care of in AMOS with the command 'Swap'.  The next lines do this with both
  1708. '  the X and Y type variables.  Simple eh? Ha ha.
  1709. '
  1710.    If X1<X Then Swap X,X1
  1711.    If Y1<Y Then Swap Y,Y1
  1712. '
  1713. '  Another 1/50 of a second pause. 
  1714. '
  1715.    Wait 1
  1716. '
  1717. '  And we grab the bob (brush) with the next line.  We are using bob 80 just 
  1718. '  to be on the safe side but any number other than bobs used by the program 
  1719. '  are equally well available - up to the limit you have defined in your 
  1720. '  AMOS configuration. The same line also sets the hot-spot of our bob.  This
  1721. '  blockbusters sounding command simply positions a point on the newly cut 
  1722. '  bob that the computer uses to position it on the screen, and by using the 
  1723. '  value $0 (hex) we tell the computer that we want the hot spot positiong 
  1724. '  at the top-left corner.  A table of preset positions can be found in the
  1725. '  AMOS manual, as well as instructions on how to place the Hot-Spot at any
  1726. '  X,Y location. 
  1727. '
  1728.    Get Bob ,80,X,Y To X1,Y1 : Hot Spot 80,$0
  1729. '
  1730. '  The next line puts all of the above variables into a new set, a copy, if  
  1731. '  you will, that will stay static, unlike the above that will change as soon
  1732. '  as the mouse is moved.  These are used by the computer so it can remember 
  1733. '  the point at which the bob (brush) was cut from .. more later ! 
  1734. '
  1735.    BX=X : BY=Y : BX1=X1 : BY1=Y1
  1736. '
  1737. '  A label.
  1738. '
  1739.    BEGIN2:
  1740. '
  1741. '  Dont be put off by the next few lines, there is nothing complex here, but I 
  1742. '  will go through them singly so you can grasp what each line is doing. It
  1743. '  may also help you to understand what we are doing if you what state this
  1744. '  procedure is currently at.  Well, at this point the user has just cut out 
  1745. '  his brush and is locating a point at which he is going to paste it into his 
  1746. '  picture.  From the above label onwards this part will continually move the
  1747. '  bob number 80 (the brush) to the current mouse co-ordinates, but we also
  1748. '  have to check if the user has selected any other command that will alter
  1749. '  the appearance of the brush...
  1750. '    
  1751. '  First we can check if the user wants the brush flipped horizontally by
  1752. '  reading the variable HFLIP.  This variable will hold a value of 1 if the
  1753. '  brush is to be flipped.  If this isn't the case then we just move the brush 
  1754. '  to the current mouse co-ordinates without any change.  Just as a precaution 
  1755. '  we set the hot-spot to the top left corner of the bob again as flipping the 
  1756. '  brush will also flip the hot-spot, and we always want to handle this brush
  1757. '  from the top-left corner. 
  1758. '
  1759.    If HFLIP=0 Then Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),80 : Hot Spot 80,$0
  1760. '
  1761. '  If the HFLIP variable holds a value of 1 then we must flip the bob on its 
  1762. '  horizontal axis.  This again is a command of AMOS' and couldn't be simpler
  1763. '  to implement.  When we display the bob with the 'Bob' command, the last 
  1764. '  number in the line holds the number of the bob to be displayed.  If we
  1765. '  use the command 'Hrev' instead of a lone bob number, the bob number in
  1766. '  brackets will be flipped horizontally.  Again we reset the Hot-Spot.
  1767. '
  1768.    If HFLIP=1 Then Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),Hrev(80) : Hot Spot 80,$0
  1769. '
  1770. '  Next we have to check if the brush is to be displayed flipped vertically
  1771. '  as well as horizontally, i.e should the brush be reversed ?  We already 
  1772. '  have seen that the HFLIP variable holds the status of the horizontal flip 
  1773. '  so it should only follow that the VFLIP variable should hold the status of
  1774. '  the vertical.  Again, AMOS makes this easy for us by supplying the command
  1775. '  'Rev'.  When used, this command will reverse the bob number in brackets.
  1776. '  This is what the next line does, and of course, resets the Hot-Spot.
  1777. '
  1778.    If HFLIP=1 and VFLIP=1 Then Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),Rev(80) : Hot Spot 80,$0
  1779. '
  1780. '  Now we check for just the vertical flip.  If the conditions at the start of 
  1781. '  the next line are met, then we simply use another AMOS command to flip the
  1782. '  bob vertically - 'Vrev', again, the image to be flipped is placed in  
  1783. '  brackets. 
  1784. '
  1785.    If HFLIP=0 and VFLIP=1 Then Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),Vrev(80) : Hot Spot 80,$0
  1786. '
  1787. '  And next, probably the most popular line in Easy Paint.  A simple check to
  1788. '  see if the mouse has left the drawing area, and if it has, we leave this
  1789. '  procedure by jumping to the FINISHED label. 
  1790. '
  1791.    If Mouse Zone<>0 Then Goto FINISHED
  1792. '
  1793. '  Now we come to the part of this procedure that allows the user to fix his 
  1794. '  brush on to the picture, as well as drawing with it.  So to enable this 
  1795. '  we set up a loop that will only cycle while the left mouse key is pressed 
  1796. '
  1797.    While Mouse Key=1
  1798. '
  1799. '  Inside this loop, we also check to see if the co-ordinates have been  
  1800. '  requested by reading the COORDS variable.  If we find a value of 1 (on) 
  1801. '  then we jump to the COORDS procedure to display them. 
  1802. '
  1803.       If COORDS=1 Then Proc COORDS
  1804. '
  1805. '  Yes, again !  Check for the mouse to leave the drawing area (zone 0) and
  1806. '  if it does then we leave this procedure by jumping to the FINISHED label
  1807. '  with the next line. 
  1808. '
  1809.       If Mouse Zone<>0 Then Goto FINISHED
  1810. '
  1811. '  Now we turn off the bob we cut from the display (80) with the next command. 
  1812. '  We do this just to remove it from the display, this command does not  
  1813. '  delete the bob from memory. 
  1814. '
  1815.       Bob Off 1
  1816. '
  1817. '  And reset the hot-spot - just in case.
  1818. '
  1819.       Hot Spot 80,$0
  1820. '
  1821. '  Next, as before, we have got to know what state the bob is in, i.e. is it 
  1822. '  reversed or flipped ?  The next four lines do exactly the same as the 
  1823. '  others except that these are pasting-fixing-the brush on to the display.  
  1824. '
  1825.       If HFLIP=0 and VFLIP=0 Then Paste Bob X Screen(X Mouse),Y Screen(Y Mouse),80
  1826.       If HFLIP=1 and VFLIP=0 Then Paste Bob X Screen(X Mouse),Y Screen(Y Mouse),Hrev(80)
  1827.       If HFLIP=1 and VFLIP=1 Then Paste Bob X Screen(X Mouse),Y Screen(Y Mouse),Rev(80)
  1828.       If HFLIP=0 and VFLIP=1 Then Paste Bob X Screen(X Mouse),Y Screen(Y Mouse),Vrev(80)
  1829. '
  1830. '  And return the loop with the next line. 
  1831. '
  1832.    Wend 
  1833. '
  1834. '  But of course, if no button is pressed, we still want to display the bob
  1835. '  on our screen.  So the next line jumps back up to the label BEGIN2. 
  1836.    Goto BEGIN2
  1837. '
  1838. '  And label the end of this procedure with ...
  1839. '
  1840.    FINISHED:
  1841. '
  1842. '  Then turn off any bobs that may have slipped through the net. 
  1843. '
  1844.    Bob Off 
  1845. '
  1846. '  Now end the procedure. Thankity fuck for thatity that twat. 
  1847. '
  1848. End Proc
  1849. '
  1850. '  Next up is the procedure responsible for magnifying portions of the 
  1851. '  screen.  There's a little bit of maths involved but nothing heavy.  If
  1852. '  you would care to read the notes supplied regarding Easypaint then you
  1853. '  will see a graphical representation of what is actually happening when
  1854. '  we use this procedure.  Other than the actual magnifying command (Zoom) 
  1855. '  the procedure adheres to exactly the same format as all the previous  
  1856. '  procedures.  I also haven't documented it because its shit at the moment  
  1857. '
  1858. Procedure F13
  1859. '
  1860. '  This beginning is terribly fucked at the moment.
  1861. '12
  1862.    If T<>13 Then Paste Bob XB,YB,BO
  1863.    Paste Bob 292,114,34
  1864.    XB=292 : YB=114 : BO=12 : T=13
  1865. Get Block 1,8,8,176,176
  1866.    BEGIN:
  1867.    Repeat 
  1868.       If COORDS=1 Then Proc COORDS
  1869. If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
  1870.  Until X Screen(X Mouse)<240
  1871.    Gr Writing 2
  1872. Ink I
  1873. Wait Vbl 
  1874. While Mouse Key=0
  1875.       X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  1876. X=(X/8)*8
  1877. Y=(Y/8)*8
  1878. Wait 5
  1879.        Ink I : Box X,Y To X+40,Y+40
  1880. Wait 5
  1881.        Ink I : Box X,Y To X+40,Y+40
  1882.       If Mouse Zone<>0 Then Gr Writing 1 : Goto FINISHED
  1883.    Wend 
  1884.    BEGIN2:
  1885. Gr Writing 1
  1886. Ink 0 : Bar 12,28 To 147,162
  1887. Ink I
  1888. Box 14,30 To 145,161
  1889. '  These hold the position of the area to be zoomed
  1890. WIDTH=(X/8)*8
  1891. HEIGHT=(Y/8)*8
  1892. Repeat 
  1893. A$=Inkey$
  1894. LLKKOO=Scancode
  1895.  FASTZOOM
  1896. If LLKKOO=79 Then WIDTH=WIDTH-8
  1897. If LLKKOO=78 Then WIDTH=WIDTH+8
  1898. If LLKKOO=76 Then HEIGHT=HEIGHT-8
  1899. If LLKKOO=77 Then HEIGHT=HEIGHT+8
  1900. MZZ=Mouse Zone
  1901. If MZZ=22 and Mouse Key=1 Then I=Point(X Screen(X Mouse),Y Screen(Y Mouse)) : Proc ZCOLBAR : Ink I
  1902. While Mouse Key=1
  1903. TX=(X Screen(X Mouse)/4)+WIDTH-4 : TY=(Y Screen(Y Mouse)/4)+HEIGHT-8
  1904. Wait 2
  1905. TX1=(X Screen(X Mouse)/4)+WIDTH-4 : TY1=(Y Screen(Y Mouse)/4)+HEIGHT-8
  1906. FASTZOOM
  1907. NULL:
  1908. A$=Inkey$
  1909. If A$=" " Then Goto FINISHED
  1910. X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  1911. MZZ=Mouse Zone
  1912. If MZZ=22 and Mouse Key=1 Then I=Point(X Screen(X Mouse),Y Screen(Y Mouse)) : Proc ZCOLBAR : Ink I
  1913. If X<14 or X>145 or Y<30 or Y>161 Then Goto NULL
  1914. Draw TX,TY To TX1,TY1
  1915. Wend 
  1916. SET=0
  1917. Until A$=" "
  1918.    FINISHED:
  1919. Put Block 1
  1920. End Proc
  1921. '
  1922. '  Nothing in the next procedure 
  1923. '
  1924. Procedure F14
  1925.    If T<>14 Then Paste Bob XB,YB,BO Else Goto FINISHED
  1926.    Paste Bob 305,114,35
  1927.    XB=305 : YB=114 : BO=13 : T=14
  1928.    FINISHED:
  1929. End Proc
  1930. '
  1931. '  Nothing in the next procedure 
  1932. '
  1933. Procedure F15
  1934.    If T<>15 Then Paste Bob XB,YB,BO Else Goto FINISHED
  1935.    Paste Bob 292,127,73
  1936.    XB=292 : YB=127 : BO=72 : T=15
  1937.    If PAGE=0 Then Change Mouse 3 : On Error Proc SWERROR : Spack 0 To 14 : Unpack 15 To 0 : PAGE=1 : Proc SETUPSCREEN : Change Mouse 2
  1938.    FINISHED:
  1939. End Proc
  1940. '
  1941. '  Nothing in the next procedure 
  1942. '
  1943. Procedure F16
  1944.    If T<>16 Then Paste Bob XB,YB,BO Else Goto FINISHED
  1945.    Paste Bob 305,127,40
  1946.    XB=305 : YB=127 : BO=17 : T=16
  1947.    If PAGE=1 Then Change Mouse 3 : On Error Proc SWERROR : Spack 0 To 15 : Unpack 14 To 0 : PAGE=0 : Proc SETUPSCREEN : Change Mouse 2
  1948.    FINISHED:
  1949. End Proc
  1950. '
  1951. '  Next comes the procedure that belongs to the 'UNDO' button.  It's very  
  1952. '  simple, just copying screen 1 to the current drawing screen - screen 0
  1953. '  whenver it is called
  1954. '
  1955. Procedure FUNDO
  1956. '
  1957. '  We check here if the last procedure called was this one, and if not 
  1958. '  we paste the un-highlighted bob on the menu bar for the last used pro-
  1959. '  cedure. 
  1960. '
  1961. '
  1962. '  Now we paste the highlighted bob for this procedure on the menu bar.
  1963. '
  1964.    Paste Bob 292,140,36
  1965. '
  1966. '
  1967. '  Label the 'doing' part of this procedure next.
  1968. '
  1969.    BEGIN:
  1970. '
  1971. '  And set the skip variable to one.  The tells the procedure that checks
  1972. '  the various screen zones that this procedure has been used and not to 
  1973. '  come here again until some kind of drawing operation has been done that 
  1974. '  will justify coming here again. 
  1975. '
  1976.    SKIP=1
  1977. '
  1978. '  Then we copy the drawing area from screen 1 back to screen 0.  The numbers
  1979. '  just tell the computer ONLY to copy to drawing area and not the title and 
  1980. '  menu bars.
  1981. '
  1982.    Screen Copy 1,1,11,290,263 To 0,1,11
  1983. '
  1984. '  Then we bring the newly copied image to the front of the display with the 
  1985. '  next line.
  1986. '
  1987.    Screen To Front 0
  1988.    Paste Bob 292,140,14
  1989. '
  1990. '  And end the procedure ... 
  1991. '
  1992. End Proc
  1993. '
  1994. '  Next up is the screen clearing procedure and this must be the simplest  
  1995. '  ever.  It simply uses the AMOS command 'Cls' with the dimensions of our 
  1996. '  drawing area to clear both screen 0 and 1.  
  1997. '
  1998. Procedure FCLS
  1999. '
  2000. '  I wont bother boring you with the next lines as we've gone over them
  2001. '  seventeen times already and these are no different. 
  2002. '
  2003.    Paste Bob 305,140,37
  2004.    BEGIN:
  2005. '
  2006. '  Here we just set the graphics pointer to screen 0 and then clear it 
  2007. '  will the 'Cls' command and the dimensions of our screen.
  2008. '
  2009.    Screen 0 : Cls 0,1,11 To 290,263
  2010. '
  2011. '  Same again for screen 1 
  2012. '
  2013.    Screen 1 : Cls 0,1,11 To 290,263
  2014. '
  2015. '  And reset the graphics pointer back to screen 0 for further drawing.
  2016. '
  2017.    Screen 0
  2018. '
  2019. '  We paste the un-highlighted bob for this procedure on the menu bar our
  2020. '  selves, because this procedure ends immediately.
  2021. '
  2022.    Paste Bob 305,140,15
  2023. '  
  2024. '  And end it with the next line.
  2025. '
  2026. End Proc
  2027. '
  2028. '
  2029. '  Down here is the procedures that actually do something, the ones that 
  2030. '  do the hard work.  All of procedures above are just responsible for 
  2031. '  calling the ones down here.  Some do seem a little daunting, but as before
  2032. '  if you stick with me as we plough through them, you'll soon see that there
  2033. '  is nothing in them that will bring out a sweat.  As it goes, Easypaint  
  2034. '  was a very simple program to write, the hardest part being writing this 
  2035. '  documentation!  So don't lose heart now.
  2036. '
  2037. Procedure RAYLINE
  2038.    While Mouse Key=0
  2039.       X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  2040.    Wend 
  2041.    BEGIN:
  2042.    While Mouse Key=1
  2043.       X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
  2044.    Wend 
  2045.    Draw X,Y To X1,Y1
  2046.    X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  2047.    If Mouse Key=2 Then Goto FINISHED
  2048.    Goto BEGIN
  2049.    FINISHED:
  2050. End Proc
  2051. Procedure AIRBRUSH
  2052. PROG=20
  2053.    BEGIN:
  2054. Repeat 
  2055. If Mouse Key=2 or Mouse Zone<>0 Then Goto FINISHED
  2056. If Mouse Zone=22 and Mouse Key=1
  2057. I=Point(X Screen(X Mouse),Y Screen(Y Mouse))
  2058. Ink I
  2059. Proc ZCOLBAR
  2060. End If 
  2061. Until Mouse Key<>0
  2062. _SCOPY
  2063. While Mouse Key=1
  2064.    If Mouse Zone<>0 and Mouse Zone<>22 Then Goto FINISHED
  2065.       X1=Rnd(10) : Y1=Rnd(10)
  2066.       X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  2067. If X<6 or X>284 or Y<16 or Y>257 Then Goto BEGIN
  2068. Ink I : Plot X-5+X1,Y-5+Y1
  2069.       If DENSITY=0 Then Goto FINISHED Else For LOP=1000 To DENSITY*10 Step -1 : Next LOP
  2070.       MIDDLE:
  2071.    Wend 
  2072.    Goto BEGIN
  2073.    FINISHED:
  2074. End Proc
  2075. '
  2076. '  Here's the cross-hairs procedure - those horizontal and vertical lines
  2077. '  that cross through the mouse pointer.  Again, extremely easy to implement.
  2078. '
  2079. Procedure CROSSHAIRS
  2080. '
  2081. '  First of all we don't want the cross-hairs to be writing over any of the
  2082. '  users graphics so we set the drawing mode to XOR.  This is the term also
  2083. '  known as 'Exclusive Or', loosely translated means that anything drawn twice 
  2084. '  in the same place will be removed without harming existing graphics.
  2085. '
  2086.    Gr Writing 2
  2087. '
  2088. '  And we mark the actual 'doing' part of this procedure with the popular
  2089. '  label 'Begin' 
  2090. '
  2091.    BEGIN:
  2092. '
  2093. '  Now we load the X and Y variable with the current mouse position on the 
  2094. '  screen because we will need these positions to draw our cross-hairs.
  2095. '
  2096.    X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  2097. '
  2098. '  Next up comes a check on variables.  First we check the X variable to see 
  2099. '  if it is less than 0 or greater than 289.  The numbers are the left and 
  2100. '  right borders of the drawing area, and if the X variable exceeds either one 
  2101. '  then we dont want to past that point do we, otherwise the menu bar and top  
  2102. '  title line will become all messy! Otherwise we jump to the FINISHED label 
  2103. '  if the next line checks out.  
  2104. '
  2105. '  If X<0 or X>289 Then Goto FINISHED
  2106. '
  2107. '  Same now for the Y variable.  Remember the Y variable holds the vertical  
  2108. '  position of the mouse, so we check if Y is less than 12 (the top of the 
  2109. '  drawing area) or greater than 263 (the bottom of the drawing area).  If 
  2110. '  either proves to be true then we jump to the FINISHED label to end this 
  2111. '  procedure.  You could just Run this program now to see the effect when
  2112. '  the cross-hairs are switched on and you leave the drawing area. 
  2113. '
  2114.    If Y<12 or Y>263 Then Goto FINISHED
  2115. '
  2116. '  Now we simply draw to straight lines using the position of the mouse we 
  2117. '  just put into the variables X and Y.  First we draw the vertical line the 
  2118. '  size of the screen X pixels horizontally.  Note that there is a graphic 
  2119. '  description of these two lines in the notes supplied in the package, look 
  2120. '  under Easypaint.
  2121. '
  2122.    Draw X,13 To X,263
  2123. '
  2124. '  Then we draw the horizontal line the size of the drawing area using the 
  2125. '  Y variable as a starting point. 
  2126. '
  2127.    Draw 0,Y To 289,Y
  2128. '
  2129. '  Another label now.  This one preceeds the next line for a good purpose. 
  2130. '  If the user stops moving the mouse then we dont want to keep drawing the
  2131. '  cross-hairs all the time do we ?  Not only is it pointless but it also
  2132. '  generated an annoying flicker, this label stops this by giving this 
  2133. '  procedure somewhere to go without re-drawing the lines. 
  2134. '
  2135.    BEGIN2:
  2136. '
  2137. '  Here's the check that will see if the mouse is stationary.  It does this
  2138. '  by checking the current position of the mouse with the last positions we
  2139. '  previously stored in X and Y.  If both match then we jump to the above
  2140. '  label. Since this is a potentially close loop we must also check for the
  2141. '  mouse to leave to drawing area
  2142. '
  2143. If Mouse Zone<>0 or Mouse Key=1 Then Goto BEGIN3 : 
  2144.    If X Screen(X Mouse)=X and Y Screen(Y Mouse)=Y Then Goto BEGIN2
  2145. BEGIN3:
  2146. '
  2147. '  Next is a wait for a vertical blank.  This is the time it takes the 
  2148. '  beam in your TV or monitor to return to the top of the picture to start 
  2149. '  burning phospur again.  Pointless info maybe, but it helps to reduce the
  2150. '  flicker when drawing the cross-hairs. 
  2151. '
  2152.    Wait Vbl 
  2153. '
  2154. '  And now we draw the cross-hairs again, exactly the same as before to remove 
  2155. '  them from the display.  We are still in XOR mode so nothing will be 
  2156. '  destroyed on the users picture. 
  2157. '
  2158.    Draw X,12 To X,263
  2159.    Draw 0,Y To 289,Y
  2160. '
  2161. '  And we set the drawing mode back to normal with the next command
  2162. '
  2163.    Gr Writing 1
  2164. '
  2165. '  We still use the FINISHED label to mark the end of this procedure should
  2166. '  any line above want to end. 
  2167. '
  2168.    FINISHED:
  2169. '
  2170. '  Of course, 'End Proc' tells the computer that this is the end of this 
  2171. '  procedure.  NOTE, you will have probably noticed that this procedure only 
  2172. '  draws the cross-hairs once and then ends, it is the reponsibility of other
  2173. '  procedure to call this procedure in their main loop, as I'm sure you can  
  2174. '  remember !
  2175. '
  2176. End Proc
  2177. '
  2178. '  Now the smallest procedure in this program, three lines that simply copy  
  2179. '  an exact image of the drawing area into screen 1.   
  2180. '
  2181. Procedure _SCOPY
  2182. '
  2183. '  The next line does the copying, the numbers are the co-ordinates of the 
  2184. '  drawing area.  A screen chart is available in the notes that accompany
  2185. '  this program, and don't forget that command formats can be found in the 
  2186. '  AMOS user guide you got with your AMOS package. 
  2187. '
  2188.    Screen Copy 0,1,11,290,263 To 1,1,11
  2189. '
  2190. '  Now we set the graphics pointer back to Screen 0, just to make sure that
  2191. '  our drawing operations will take place on our drawing, and not some spare 
  2192. '  screen. 
  2193. '
  2194.    Screen 0
  2195. '
  2196. '  And end this procedure. 
  2197. '
  2198. End Proc
  2199. '
  2200. '  Another small procedure now.  This one prints the co-ordinates of the 
  2201. '  mouse on the top menu bar.
  2202. '
  2203. Procedure COORDS
  2204. '
  2205. '  We start by loading the co-ordinates of the mouse into the variables XX 
  2206. '  and YY.   
  2207. '
  2208.    XX=X Screen(X Mouse)
  2209.    YY=Y Screen(Y Mouse)
  2210. '
  2211. '  The next line may seem a little alien ?  What we are doing is loading the 
  2212. '  variable C$ with a string conversion of the variables XX and YY.  Why ?   
  2213. '  Well we need to convert the numeric variables into strings because of the 
  2214. '  way we need to display the information with the 'Text' command. It's best 
  2215. '  to put the information into a single string variable (C$) than have lots
  2216. '  of conditions in the 'Text' command, otherwise we will have lots and lots 
  2217. '  of hassle.
  2218. '
  2219.    C$=Str$(XX)+" "+Str$(YY)+" "
  2220. '
  2221. '  Now we set the ink colour to 0 (black) regardless of the ink colour the 
  2222. '  program is currently using.  We use the 'Text' command instead of a 'Print' 
  2223. '  for the benefit of being able to position our text to the nearest pixel 
  2224. '  rather than character position.  The numbers the pixel position on the
  2225. '  top title bar.
  2226. '
  2227. Gr Writing 1 : Ink 0 : Text 232,7,C$
  2228. '
  2229. '  And end the procedure.
  2230. '
  2231. End Proc
  2232. '
  2233. '  The next three procedure are used to read the pull-down menus.  It may
  2234. '  help you to understand what each one is doing by reading the notes  
  2235. '  supplied for the Easy Paint program that explain the menu' layout.
  2236. '  Due to the length of the program lines, it has also been necessary for  
  2237. '  this and other reasons to explain these procedures in the notes.  I 
  2238. '  apologise for any inconvenience this may cause, but I'm sure you'll 
  2239. '  see it is the better way of doing it. 
  2240. '
  2241. Procedure MENCHECK1
  2242. '
  2243. '  The way pull down menus are created is a bit like a family tree, with 
  2244. '  each option having options leading from it, and those also having options 
  2245. '  leading from them.  We can check which option has been selected by using
  2246. '  the 'Choice' command with a value in brackets denoting which part of the
  2247. '  'tree' we want to read.  So the next line reads each tree into three
  2248. '  variables A, B and C.  More information is available in the AMOS manual 
  2249. '  and the notes supplies with this program
  2250. '
  2251.    A=Choice(1) : B=Choice(2) : C=Choice(3)
  2252. '
  2253. '  Now we come to read the variables to find which menu option has been  
  2254. '  selected, there is no quick way around this, so each option has to be 
  2255. '  read individually.  What we do know though, is that we wouldn't be in   
  2256. '  this procedure unless an option had been selected from the Picture
  2257. '  menu.  Remember a long while back at the start of this program we set 
  2258. '  up an interrupt that read the pull-down menus full time ?  Well, we also
  2259. '  told the computer to jump to the respective procedures, these being 
  2260. '  MENCHECK1, MENCHECK2 and MENCHECK3 which relate to the menu options of
  2261. '  'Picture', 'Brush' and 'Prefs'.  It's really quite pointless explaining 
  2262. '  every line as you can see what is being done, the variables A, B and C
  2263. '  hold numbers that relate to the option selected.  We just check these 
  2264. '  numbers and jump to the procedure that relates that option. 
  2265. '
  2266. '  The FILESELECTOR has three types to it - LOAD, SAVE and DELETE, the number
  2267. '  in brackets holds the type we wish to use.
  2268. '
  2269.    If A=1 and B=1 Then Proc FILESELECTOR[1] : Screen 0
  2270.    If A=1 and B=2 Then Proc FILESELECTOR[2] : Screen 0
  2271.    If A=1 and B=3 Then Proc FILESELECTOR[3] : Screen 0
  2272. '
  2273. '  The procedure SELECTPALETTE is the palette selector.  
  2274. '
  2275.    If A=1 and B=4 and C=1 Then Proc SELECTPALETTE
  2276. '
  2277. '  The procedure DEFPALETTE is responsible for setting the pallete back to 
  2278. '  its default values. 
  2279. '
  2280.    If A=1 and B=4 and C=2 Then Proc DEFPALETTE
  2281. '
  2282. '  The next 6 lines are much larger than this display so you may need to 
  2283. '  scroll the display to read them fully.  The next two are used to copy 
  2284. '  the spare page between the memory banks and screen 0.  The 'Spack'
  2285. '  command is used to compress a screen display into a given memory bank 
  2286. '
  2287.    If A=1 and B=5 and C=1 and PAGE=0 Then Change Mouse 3 : On Error Proc SWERROR : Spack 0 To 14 : Unpack 15 To 0 : PAGE=1 : Proc SETUPSCREEN : Change Mouse 2 : Goto FINISHED
  2288.    If A=1 and B=5 and C=1 and PAGE=1 Then Change Mouse 3 : On Error Proc SWERROR : Spack 0 To 15 : Unpack 14 To 0 : PAGE=0 : Proc SETUPSCREEN : Change Mouse 2 : Goto FINISHED
  2289.    If A=1 and B=5 and C=2 and PAGE=0 Then Change Mouse 3 : Spack 0 To 15 : Proc SETUPSCREEN : PAGE=1 : Change Mouse 2 : Goto FINISHED
  2290.    If A=1 and B=5 and C=2 and PAGE=1 Then Change Mouse 3 : Spack 0 To 14 : Proc SETUPSCREEN : PAGE=0 : Change Mouse 2 : Goto FINISHED
  2291.    If A=1 and B=5 and C=3 and PAGE=0 Then Change Mouse 3 : Erase 15 : Proc SETUPSCREEN : Change Mouse 2 : Goto FINISHED
  2292.    If A=1 and B=5 and C=3 and PAGE=1 Then Change Mouse 3 : Erase 14 : Proc SETUPSCREEN : Change Mouse 2 : Goto FINISHED
  2293.    If A=1 and B=6 Then Edit 
  2294.    FINISHED:
  2295.    On Menu On 
  2296. End Proc
  2297. Procedure MENCHECK2
  2298.    A=Choice(1) : B=Choice(2) : C=Choice(3)
  2299.    If A=2 and B=1 and C=1 and BY1>BY Then Proc BHALF
  2300.    If A=2 and B=1 and C=2 and BY1>BY Then Proc BDOUBLE
  2301.    If A=2 and B=1 and C=3 and BY1>BY Then Proc BDOUBLEHORIZ
  2302.    If A=2 and B=1 and C=4 and BY1>BY Then Proc BDOUBLEVERT
  2303.    If A=2 and B=2 and C=1 and HFLIP=0 Then HFLIP=1 : Goto FINISHED
  2304.    If A=2 and B=2 and C=1 and HFLIP=1 Then HFLIP=0 : Goto FINISHED
  2305.    If A=2 and B=2 and C=2 and VFLIP=0 Then VFLIP=1 : Goto FINISHED
  2306.    If A=2 and B=2 and C=2 and VFLIP=1 Then VFLIP=0 : Goto FINISHED
  2307.    If A=2 and B=3 and C=1 Then Proc FLIP180
  2308.    FINISHED:
  2309.    On Menu On 
  2310. End Proc
  2311. Procedure MENCHECK3
  2312.    A=Choice(1) : B=Choice(2) : C=Choice(3)
  2313.    If A=3 and B=1 Then Bell : If COORDS=0 Then COORDS=1 Else COORDS=0 : Text 232,7,"        "
  2314.    If A=3 and B=2 Then Proc AIRPOWER
  2315.    On Menu On 
  2316. End Proc
  2317. '
  2318. '  Next comes a small procedure that simply amends variables and has nothing   
  2319. '  at all to do with any graphic operations straight to the screen.  What we 
  2320. '  are doing inside this procedure is simply switching variable quantities 
  2321. '  if our conditions are met - if either HFLIP or VFLIP = 1 then we set them 
  2322. '  to 0.  Likewise if either equal 0 when we enter this procedure then we set
  2323. '  them to 1.  The variables themselves are fairly self explanatry, HFLIP  
  2324. '  holds a value that tells us if the current brush is flipped (1) or not  
  2325. '  horizontally, and VFLIP holds a value that tells us if the current brush
  2326. '  is also flipped (1) or not vertically.  Not much else really. 
  2327. '
  2328. Procedure FLIP180
  2329.    If HFLIP=0 Then HFLIP=1 : Goto BEGIN
  2330.    If HFLIP=1 Then HFLIP=0 : Goto BEGIN
  2331.    BEGIN:
  2332.    If VFLIP=0 Then VFLIP=1 : Goto FINISHED
  2333.    If VFLIP=1 Then VFLIP=0 : Goto FINISHED
  2334.    FINISHED:
  2335. End Proc
  2336. '
  2337. '  Here is the procedure that reads the directory of a disc into the array 
  2338. '  we dimensioned a long time ago at the start of this program.  Nothing at
  2339. '  all special in here apart from a couple of AMOS commands you might not be 
  2340. '  familiar with - 'Dir First$()' and 'Dir Next$'.  I'll explain them as 
  2341. '  we come to them.
  2342. '
  2343. Procedure GDIR
  2344. '
  2345. '  Taking the next variables in order, the first is simply a counter used by 
  2346. '  this procedure and the zone checking procedure to show that this procedure
  2347. '  has been called succesfully, the same for the next variable.  The variable
  2348. '  XX is used to hold the start point in the array FAME$ that the directory
  2349. '  will be loaded into.
  2350. '
  2351.    FRESH=1
  2352.    XYZ=1
  2353.    XX=1
  2354. '
  2355. '  Okay, the first of the AMOS commands.  What 'Dir First$()' does is to 
  2356. '  first check the path (Disk Drive) it will look at, we simply tell it to 
  2357. '  look at the current path held in the command 'Dir$' - this is always
  2358. '  loaded with some information because AMOS itself reads this variable when 
  2359. '  you click on the file selector.  Then it reads the length and name of the 
  2360. '  first file on the disk ('Dir$') and puts it into the array FAME$ at 
  2361. '  position 1 (the variable XX holds this value).  This command - 'Dir First$' 
  2362. '  also loads the entire directory into memory, which we then need to read 
  2363. '  into our array with the next few lines
  2364. '
  2365.    FAME$(XX)=Dir First$(Dir$)
  2366. '
  2367. '  So we start a simple 'For/Next' Loop using the same counter variable as 
  2368. '  before (XX) with a start value of 2.  Remember that the first position of 
  2369. '  the FAME$ array was filled in the previous line 
  2370. '
  2371.    For XX=2 To 50
  2372. '
  2373. '  And we use the command 'Dir Next$' to read each directory listing from  
  2374. '  memory and store it in the FAME$ array. 
  2375. '
  2376.       FAME$(XX)=Dir Next$
  2377. '
  2378. '  And we increment the XX variable in the loop with the next command. 
  2379. '
  2380.    Next XX
  2381. '
  2382. '  Before the command that will end this procedure I should point out that 
  2383. '  this procedure will only read 50 directory entries from any disc, this  
  2384. '  can be easily altered by changing the value at the start of this program
  2385. '  that dimensions the FAME$ array, and then altering the above loop to this 
  2386. '  new value.
  2387. '
  2388. End Proc
  2389. '
  2390. '  Yes you've guessed it, I've even used a procedure to move the path into 
  2391. '  a sub-directory, they are just so convenient!  Again though, nothing
  2392. '  difficult here apart from the first line, but then, that's nothing really 
  2393. '  hard as you'll see ...
  2394. '  
  2395. Procedure UPATH
  2396. '
  2397. '  Okay, from the beginning you see the variable PATH2$, this is where we
  2398. '  will set the string variable which will eventually tell the computer which
  2399. '  path we want to enter and is only temporary.  Next comes the 'Mid$' command 
  2400. '  that we use to snatch pieces of a string variable with.  A little insight 
  2401. '  would be useful here ... when the user clicks on a directory in the file
  2402. '  selector, this procedure checks which line the user has clicked and just
  2403. '  grabs the whole line from the FAME$ array, the problem with that is that
  2404. '  whatever it grabs also has things such as the length of the file held in
  2405. '  the string, so we need to strip this info out so we just have the name of 
  2406. '  the directory and nothing else - not even spaces.  We also don't want the 
  2407. '  asterixes that are displayed on the file selector (*) before a directory
  2408. '  listing.  So knowing this we know we want to start at the second character
  2409. '  of our string (to miss the *) and grab the whole string up to the 27th
  2410. '  character, as this is the width of the file selectors display, then we can
  2411. '  be sure of getting all the information.  Also, the part of the next line
  2412. '  that reads thus - (FAME$(XYZ+LINE-2) can be explained thus, thus !!  XYZ
  2413. '  is simply a dumb variable that holds a value of 1 full time and does
  2414. '  nothing else. The variable LINE is the line position on the file selector 
  2415. '  of which the user has selected a directory, by subtracting 2 from this
  2416. '  variable we get the position in the array of the directory! 
  2417. '
  2418.    PATH2$=Mid$(FAME$(XYZ+LINE-2),2,27)
  2419. '
  2420. '  Now we set a loop that will move through 1 to 27 so we can check each 
  2421. '  character of the PATH2$ variable for spaces.  If we find a space then we
  2422. '  mark the postion in the KI variable and end the loop.  Remember, this is
  2423. '  is so can remove any spaces from the string before we ask the computer to 
  2424. '  read the directory from our variable. 
  2425. '
  2426.    For LOP=1 To 27
  2427.       PL$=Mid$(PATH2$,LOP,1)
  2428.       If PL$=" " Then KI=LOP : LOP=27
  2429.    Next LOP
  2430. '
  2431. '  Next we set the variable PATH$ with the final draft of our task by using
  2432. '  a value of KI-1 so we dont have any spaces at all in the string.
  2433. '
  2434.    PATH$=Mid$(PATH2$,1,KI-1)
  2435. '
  2436. '  Then we need to set the actual directory that AMOS uses to our string 
  2437. '  while also adding the oblique character (/) so AMOS knows it is to access 
  2438. '  a directory and nothing else. 
  2439. '
  2440.    Dir$=Dir$+PATH$+"/"
  2441. '
  2442. '  Then get the directory again by calling the GDIR procedure. 
  2443. '
  2444.    Proc GDIR
  2445. '
  2446. '  And end this fucking twat of a procedure. 
  2447. '
  2448. End Proc
  2449. '
  2450. '  I can tell you that documenting this next baby wasn't exactly my idea of
  2451. '  a thrilling time, but please don't be put off.  This is the main body of
  2452. '  the fileselector and can load, save, delete and rename files so it's not
  2453. '  that long for what it does, and it isn't really difficult to grasp. 
  2454. '  Note that to call the various functions Load/Save/Delete you need to pass 
  2455. '  a number 1,2 or 3 into this procedure by using the TYPE variable. 
  2456. '
  2457. Procedure FILESELECTOR[TYPE]
  2458. '
  2459. '  We use a spare screen for the file selectors display so as not to over
  2460. '  complicate things with trillions of zones and windows all over the place
  2461. '  The next line does this screen opening. 
  2462. '
  2463.    Screen Open 3,320,276,64,Lowres : Paper 0 : Curs Off : Flash Off : Cls 
  2464. '
  2465. '  And we load the sprite palette
  2466. '
  2467.    Get Sprite Palette 
  2468. '
  2469. '  Bring the screen to the front 
  2470. '
  2471.    Screen To Front 3
  2472. '
  2473. '  And set the drawing pointer to here.
  2474. '
  2475.    Screen 3
  2476. '
  2477. '  Next we reserve the screen zones that will be used for the various buttons
  2478. '  and displays. 
  2479. '
  2480.    Reserve Zone 20
  2481. '
  2482. '  And set the FRESH variable to 0 to tell us that this procedure has just 
  2483. '  been freshly called.
  2484. '
  2485.    FRESH=0
  2486. '
  2487. '  We have reserved the zones so now we need to tell the computer at which 
  2488. '  co-ordinates to set the zones.  All the co-ordinates are held in the  
  2489. '  data statements.
  2490. '
  2491.    For LOP=1 To 20
  2492.       Read A,B,C,D
  2493.       Set Zone LOP,A,B To C,D
  2494.    Next LOP
  2495.    Data 254,55,265,68,253,137,265,150,77,158,257,168,77,174,257,184
  2496.    Data 82,189,133,201,149,189,200,201,212,189,263,200,18,189,69,201
  2497.    Data 16,55,247,62,16,64,247,70,16,72,247,78,16,80,247,86,16,88,247,94
  2498.    Data 16,96,247,102,16,104,247,110,16,112,247,118,16,120,247,126
  2499.    Data 16,128,247,134,16,136,247,142,16,144,247,150
  2500. '
  2501. '  Now we draw the boxes and bars that make up the components of the file
  2502. '  selector. 
  2503. '
  2504.    Ink 1
  2505.    Bar 12,35 To 268,156
  2506.    Ink 0 : Draw 12,50 To 268,50
  2507.    Draw 12,155 To 268,155
  2508.    Ink 0 : Bar 252,53 To 267,152
  2509.    Ink 1
  2510.    Bar 12,156 To 268,205
  2511.    Ink 0 : Bar 77,158 To 257,168
  2512.    Ink 0 : Bar 77,174 To 257,184
  2513.    Box 14,53 To 250,152
  2514. '
  2515. '  As I said earlier, this procedure is configurable to Save/Load/Delete 
  2516. '  so here we check the TYPE variable and display the relevant title.
  2517. '
  2518.    If TYPE=1 Then Locate 10,5 : Paper 1 : Pen 0 : Print "  Load Picture"
  2519.    If TYPE=2 Then Locate 10,5 : Paper 1 : Pen 0 : Print "  Save Picture"
  2520.    If TYPE=3 Then Locate 10,5 : Paper 1 : Pen 0 : Print " Delete Picture"
  2521. '
  2522. '  Next we just print the other information on the file selector.
  2523. '
  2524.    Locate 2,20 : Print "Drawer"
  2525.    Locate 2,22 : Print "File"
  2526.    Locate 2,7 : Pen 31 : Print "<DEV> DF0:"
  2527.    Locate 2,8 : Print "<DEV> DF1:"
  2528. '
  2529. '  I know some people will say its bad practice to use blitter objects (bobs)
  2530. '  for the various buttons in this program, but I belive it is best to show
  2531. '  the method in which the buttons are animated.  Of course you could just 
  2532. '  XOR a box over the buttons to show a depression.  None-the-less, this 
  2533. '  is what the next lines are doing, pasting bobs on the file selector to act
  2534. '  as buttons. You could go into direct mode now and paste the bobs yourself 
  2535. '  to see what is happening,  the bobs are listed in the supplied notes. 
  2536. '
  2537.    Paste Bob 254,56,43
  2538.    Paste Bob 254,137,44
  2539.    Paste Bob 18,189,48
  2540.    Paste Bob 82,189,47
  2541. '
  2542. '  We check the TYPE variable again here so we know which key bob to paste.
  2543. '  By key bob, I mean Save/Load/Delete buttons,  the others remain constant. 
  2544. '
  2545.    If TYPE=1 Then Paste Bob 149,189,46
  2546.    If TYPE=2 Then Paste Bob 149,189,59
  2547.    If TYPE=3 Then Paste Bob 149,189,60
  2548.    Paste Bob 212,189,45
  2549. '
  2550. '  Now we label the proper part of this procedure. 
  2551. '
  2552.    BEGIN:
  2553. '
  2554. '  Next we print the current path in the proper box on the file selector as
  2555. '  well as a number of spaces (with the Space$() command) to remove any
  2556. '  excess characters that may appear from time to time with different
  2557. '  directories.
  2558. '
  2559.    Locate 10,20 : Paper 0 : Print Dir$+Space$(20-Len(Dir$)) : Paper 1
  2560. '
  2561. '  So now we need to start scanning the mouse until the user presses a 
  2562. '  button.  We will use a 'Repeat/Until' loop for this, all the while
  2563. '  loading the MZONE variable with the current mouse zone. 
  2564. '
  2565.    Repeat 
  2566.       MZONE=Mouse Zone
  2567.    Until Mouse Key<>0
  2568. '
  2569. '  Now we need to check which zone, if any, the user selected, and then  
  2570. '  jump to the program or procedure that we require.  We can quickly check 
  2571. '  to see if the user has selected a function like 'Load' by checking the
  2572. '  MZONE variable for a value greater than 8, because all the zones other
  2573. '  than files are in zones less than 8.  The FRESH variable holds a value
  2574. '  which we can check to see if the selection requires a fresh directory.
  2575. '
  2576.    If MZONE>8 and FRESH=0 Then Gosub INIT : Goto BEGIN
  2577.    If MZONE>8 and FRESH=1 Then Gosub INIT2 : Goto BEGIN
  2578. '
  2579. '  If the value in MZONE was not trapped above then we know that MZONE will
  2580. '  hold a value less than 8, so we can use the next command to jump to the 
  2581. '  correct label relative to the value of MZONE
  2582. '
  2583.    On MZONE Gosub A,B,C,D,G,F,E,H
  2584. '
  2585. '  And if the user clicked the mouse on a null zone then we jump back to the 
  2586. '  BEGIN label to begin checking again.
  2587. '
  2588.    Goto BEGIN
  2589. '
  2590. '
  2591.    A:
  2592. '
  2593. '  ## Scroll Directory Display Up ## 
  2594. '
  2595. '  Here we simply paste a highlighted bob while the mouse key is being 
  2596. '  pressed.
  2597. '
  2598.    Paste Bob 254,56,49
  2599.    While Mouse Key=1 : Wend 
  2600.    Paste Bob 254,56,43
  2601.    If COUNT=1 Then Goto FINISHED
  2602. '
  2603. '  Decrement the count variable which is used by the PDIR procedure as a 
  2604. '  start point at which to display the directory in the file selector
  2605. '
  2606.    Dec COUNT : Proc PDIR
  2607.    FINISHED:
  2608.    Return 
  2609. '
  2610.    B:
  2611. '
  2612. '  ## Scroll Directory Display Down ## 
  2613. '
  2614. '  Here we simply paste a highlighted bob while the mouse key is being 
  2615. '  pressed.
  2616. '
  2617.    Paste Bob 254,137,50
  2618.    While Mouse Key=1 : Wend 
  2619.    Paste Bob 254,137,44
  2620. '
  2621. '  Check in here if there is anything in FAME$ to be displayed if we scroll
  2622. '  the display.
  2623. '
  2624.    If FAME$(COUNT+12)="" Then Goto FINISHED1
  2625. '
  2626. '  And increment the COUNT variable ready for the ...
  2627. '
  2628.    Inc COUNT
  2629. '
  2630. '  PDIR procedure to display the scrolled listing
  2631. '
  2632.    Proc PDIR
  2633.    FINISHED1:
  2634.    Return 
  2635. '
  2636.    C:
  2637. '
  2638. '  We have left this blank for you to experiment with, it's not vital though 
  2639. '  as the user can still select a drawer by clicking on the 'Discs' button 
  2640. '
  2641.    Return 
  2642. '
  2643.    D:
  2644. '
  2645. '  This is used to manually enter a filename for saves & stuff.  It simply 
  2646. '  calls the LININPUT procedure with the number in brackets representing 
  2647. '  X position, Y position and input length.  This procedure passes the result
  2648. '  out in the variable FIN$... 
  2649. '
  2650.    Proc LININPUT[10,22,22]
  2651. '
  2652. '  So we load our variable that holds filenames - FILENAME$ - with FIN$ - the
  2653. '  result of the line input from the last line.
  2654. '
  2655.    FILENAME$=FIN$
  2656. '
  2657. '  And return. 
  2658. '
  2659.    Return 
  2660. '
  2661.    E:
  2662. '
  2663. '  This is the 'Cancel' button subroutine.  It simply pastes a highlighted 
  2664. '  bob while the mouse key is being pressed and then jumps to the FINALEND 
  2665. '  label to end this procedure.
  2666. '
  2667.    Paste Bob 212,189,51
  2668.    While Mouse Key=1 : Wend 
  2669.    Paste Bob 212,189,45
  2670.    Goto FINALEND
  2671.    Return 
  2672. '
  2673.    F:
  2674. '
  2675. '  This subroutine is a little more complex because it has to handle three 
  2676. '  functions - Load/Save/Delete. 
  2677. '
  2678.    If TYPE=1 Then Paste Bob 149,189,52
  2679.    If TYPE=2 Then Paste Bob 149,189,65
  2680.    If TYPE=3 Then Paste Bob 149,189,66
  2681.    While Mouse Key=1 : Wend 
  2682.    If TYPE=1 Then Paste Bob 149,189,46
  2683.    If TYPE=2 Then Paste Bob 149,189,59
  2684.    If TYPE=3 Then Paste Bob 149,189,60
  2685. '
  2686. '  So here is the first function - Load.  Simply it loads an Iff picture into
  2687. '  screen 0 using the path of 'Dir$' and the filename in FILENAME$.
  2688. '
  2689.    If TYPE=1
  2690.       Screen 0 : Load Iff Dir$+FILENAME$
  2691. '
  2692. '  Then we set up the main screen display again, menu bar,title bar and screen 
  2693. '  zones, in case the picture exceeds the drawing area dimensions
  2694. '
  2695.       Proc SETUPSCREEN
  2696. '  And end this procedure by jumping to the FINALEND label 
  2697. '
  2698.       Goto FINALEND
  2699.    End If 
  2700. '
  2701. '  Now if the TYPE equals 2 (Save) we need to save the current screen, as
  2702. '  before using 'Dir$' and our FILENAME$.  The two 'Bar' commands simply 
  2703. '  clear out any out of date information from the file-selector. As before 
  2704. '  we set the screen up again and end this procedure by jumping to the 
  2705. '  FINALEND procedure. 
  2706. '
  2707.    If TYPE=2
  2708.       Screen 0
  2709.       Ink 0
  2710.       Bar 0,0 To 317,9
  2711.       Bar 292,10 To 316,263
  2712.       Save Iff Dir$+FILENAME$
  2713.       Proc SETUPSCREEN
  2714.       Goto FINALEND : 
  2715.    End If 
  2716. '
  2717. '  Finally we check the TYPE variable to see if we need anything deleting. 
  2718. '  Using the 'Kill' command to delete the required file and the 'Space$()' 
  2719. '  to clear out the text boxes.
  2720. '
  2721.       If TYPE=3
  2722.       Kill Dir$+FILENAME$
  2723.       For LINE=7 To 18
  2724.          Locate 2,LINE
  2725.          Paper 1 : Print Space$(29)
  2726.       Next LINE
  2727.       Locate 10,22 : Print Space$(22)
  2728. '
  2729. '  Then we get the directory again and print it out to show the user that
  2730. '  the task has been carried out successfully. 
  2731. '
  2732.       Proc GDIR
  2733.       Proc PDIR
  2734.    End If 
  2735.    Return 
  2736. '
  2737.    G:
  2738. '
  2739. '  In here we cater for the need to rename any file. 
  2740. '
  2741.    Paste Bob 82,189,53
  2742.    While Mouse Key=1 : Wend 
  2743.    Paste Bob 82,189,47
  2744. '
  2745. '  You can't rename nothing, so the next line checks the current filename
  2746. '  held in the FILENAME$ variable, and if nothing exists then we exit this 
  2747. '  subroutine (NOT this procedure) by jumping to the GEND label. 
  2748. '
  2749.    If FILENAME$="" Then Goto GEND
  2750. '
  2751. '  Quickly draw the rename box.  Try it !!!
  2752. '
  2753.    Ink 1 : Bar 12,210 To 268,245
  2754.    Ink 0 : Bar 22,230 To 266-8,241
  2755.    Draw 12,226 To 267,226
  2756. '
  2757. '  And display the name of the file to be renamed, limiting the display
  2758. '  to a maximum of 18 characters with the 'Mid$' command so we dont run
  2759. '  off the box ! 
  2760. '
  2761.    Locate 3,27 : Paper 1 : Print "Rename '";Mid$(FILENAME$,1,18);"' as -"
  2762. '
  2763. '  Then we call the line input procedure at 3,29 (X column/Y column) with
  2764. '  an input length of29 characters.
  2765. '
  2766.    Proc LININPUT[3,29,29]
  2767. '
  2768. '  Then rename the file to the new name held in FIN$ - remember that FIN$
  2769. '  holds the input we got from the LININPUT procedure. 
  2770. '
  2771.    Rename FILENAME$ To FIN$
  2772. '
  2773. '  Remove the rename box from the screen now by drawing a black bar over the 
  2774. '  top of it.  Crude but effective!
  2775. '
  2776.    Ink 0 : Bar 12,210 To 268,245
  2777. '
  2778. '  And now we clear out the old directory display by pasting a bar over that 
  2779. '  as well!  
  2780. '
  2781.    Ink 1 : Bar 16,55 To 247,150
  2782. '
  2783. '  And clear out the filename box with 22 spaces 
  2784. '
  2785.    Locate 10,22 : Pen 0 : Paper 0 : Print Space$(22) : Paper 1 : 
  2786. '
  2787. '  Then we get a new directory and print it out
  2788. '
  2789.    Proc GDIR
  2790.    Proc PDIR
  2791.    GEND:
  2792.    Return 
  2793. '
  2794.    H:
  2795. '
  2796. '  This subroutine does nothing except print device names(disk drives) on
  2797. '  the file selectors display, no checks are made to see if the devices
  2798. '  exist - perhaps you could check and only display the correct drives!
  2799. '
  2800.    Paste Bob 18,189,54
  2801.    While Mouse Key=1 : Wend 
  2802.    Paste Bob 18,189,48
  2803. '
  2804. '  This next loop is only used to clear out any directory listing that may 
  2805. '  be displayed on the file selector by simply print spaces in the hole
  2806. '
  2807.    For LINE=7 To 18
  2808.       Locate 2,LINE
  2809.       Print Space$(29)
  2810.    Next LINE
  2811.    Locate 2,7 : Pen 23 : Print "<DEV> DF0:"
  2812.    Locate 2,8 : Print "<DEV> DF1:"
  2813.    FRESH=0
  2814.    Return 
  2815.    Goto 2222
  2816. '
  2817. '
  2818. '  The next subroutine is called further up in this procedure when the user
  2819. '  clicks on a directory listing to display that directory listing in the
  2820. '  'file' text box.  It also does a check on the first character of the
  2821. '  listing for an asterix (*) that denotes a sub-directory, and if it finds
  2822. '  one it will get the new sub-directory or folder, by calling the PARDIR
  2823. '  subroutine. 
  2824. '
  2825.    INIT2:
  2826.    FILENAME$=Mid$(FAME$((MZONE-9)+COUNT),1,29)-" "
  2827.    If Mid$(FILENAME$,1,1)="*" Then Gosub PARDIR : Return 
  2828.    Locate 10,22 : Paper 0 : Print FILENAME$+Space$(22-Len(FILENAME$))
  2829.    Return 
  2830. '
  2831. '  Here the next subroutine actually gets the sub-directory listing and
  2832. '  displays it on the screen.  I wont waste your time by explaining what we
  2833. '  have already gone over, because we have, and there's nothing at all hard
  2834. '  here. 
  2835. '  
  2836.    PARDIR:
  2837.    L$=Mid$(FILENAME$,2,29)-" "
  2838.    L$=L$+"/"
  2839.    FILENAME$=L$
  2840.    Dir$=FILENAME$
  2841.    For LINE=7 To 18
  2842.       Locate 2,LINE
  2843.       Print Space$(29)
  2844.    Next LINE
  2845.    Proc GDIR
  2846.    Proc PDIR
  2847.    Return 
  2848. '
  2849. '  This next sub-routine is called when the file-selector is in a fresh state
  2850. '  and only the devices are displayed.  It checks which mouse zone was clicked 
  2851. '  and then sets the current directory to that drive.  Then we get a new 
  2852. '  directory and print it on the file-selector.
  2853. '
  2854.    INIT:
  2855.    If MZONE=9 Then Dir$="df0:"
  2856.    If MZONE=10 Then Dir$="df1:"
  2857.    Proc GDIR
  2858.    Proc PDIR
  2859.    Return 
  2860. '
  2861. '
  2862.    FINALEND:
  2863. '
  2864. '  We will need to close this screen when this procedure has finished to save
  2865. '  memory, so we do it now.
  2866. '
  2867.    Screen Close 3
  2868. '
  2869. '  And then bring our drawing screen back to the front of the display. 
  2870. '
  2871.    Screen To Front 0
  2872. '
  2873. '  And then end this procedure.
  2874. '
  2875. End Proc
  2876. '
  2877. '  The next procedure is the one that does the printing of the selected
  2878. '  directory on the screen.
  2879. '
  2880. Procedure PDIR
  2881. '
  2882. '  First we load the contents of the COUNT variable into the COUNT1 variable 
  2883. '  because we don't want to change the contents of COUNT.  If we did things
  2884. '  would get very messy because COUNT holds the point in the array at which
  2885. '  the current directory is displayed on the screen
  2886. '
  2887.    COUNT1=COUNT
  2888. '
  2889. '  And now we simply set a simple loop to count 11 positions.  We use the
  2890. '  values 7 to 18 so we can just take the position of the loop to print at 
  2891. '  the correct vertical position 
  2892. '
  2893.    For LINE=7 To 18
  2894. '
  2895. '  When printing the contents of the array note that we are filtering only 
  2896. '  the first 29 characters with the 'Mid$' command so we dont print more than
  2897. '  the width of the file selector. 
  2898. '
  2899.       Locate 2,LINE : Paper 1 : Print Mid$(FAME$(COUNT1),1,29)
  2900. '
  2901. '  And then we increment the COUNT1 variable next, which is used to retrieve 
  2902. '  the correct listing in the array FAME$
  2903. '
  2904.       Inc COUNT1
  2905. '
  2906. '  Then end the loop 
  2907. '
  2908.    Next LINE
  2909. '
  2910. '  And the whole procedure!  
  2911. '
  2912. End Proc
  2913. '
  2914. '  Next up is the procedure that places the palette selector on the screen 
  2915. '  Unfortunately, it is fairly long and uses a lot of numbers in places, and 
  2916. '  we do some poking about in memory.  On the whole though, fairly simple
  2917. '  and good for experience.
  2918. '
  2919. Procedure SELECTPALETTE
  2920. '
  2921. '  First we need to set up a few variables 
  2922. '
  2923.    Shared FC,BC,REZ,NCOLS,XS,TPAL,TPAL()
  2924.    Dim RGB(31)
  2925.    CL1=0 : CL2=NCOLS : SC=Screen
  2926. '
  2927. '  And then open a screen on which to display out palette selector 
  2928. '
  2929.    Screen Open 3,320,160,32,Lowres
  2930.    Curs Off : Flash Off : Get Palette 0 : Cls 0
  2931. '
  2932. '  Then set the drawing pointer to the new screen
  2933. '
  2934.    Screen 3
  2935.    Wait Vbl 
  2936. '
  2937. '  We will be needing some zones for the variuos buttons and colour areas
  2938. '  so we reserve them zones now. 
  2939. '
  2940.    Reserve Zone 43
  2941. '
  2942. '  Now we come to draw the actual palette selector on the screen with an 
  2943. '  assortment of bars and boxes, this also draws in the coloured bars that 
  2944. '  can be clicked on to select a colour to be changed.  I won't document 
  2945. '  these lines because they are just mostly screen co-ordinate calculations
  2946. '  and would be near impossible to understand.  The best way is to just try  
  2947. '  them out in direct mode to see what goes where. I also thought it was a 
  2948. '  good idea to set up the zones around the colour boxes as they were being
  2949. '  drawn so that we know exactly where the zones are going.  You will also 
  2950. '  notice a couple of maths commands - 'Mod' and 'Min', don't be put off by  
  2951. '  them, they are just tame little babies!  Let me explain here what they do 
  2952. '  so you don't have to go hunting through your AMOS User Guide, and as it 
  2953. '  happens, the 'Mod' function was not shown in my User Guide! 
  2954. '
  2955. '  'mod' is a command or function that will give you the remainder of a  
  2956. '  division.  e.g. A=7 mod 3 will place a value of 1 in the variable A.
  2957. '  A=50 mod 4 will place a value of 2 into the variable A, nothing fancy 
  2958. '  but it can come in useful, if as in this procedure, you need to know the
  2959. '  remainder of a calculation. 
  2960. '
  2961. '  'Min' on the other hand is listed in the AMOS User Guide.  This function
  2962. '  places the smallest value of two expressions into a variable.  The
  2963. '  expressions can be strings or numbers, but we only number the numbers.
  2964. '  e.g. A=Min(2,1) will place a value of 1 in the variable A, because 1 was
  2965. '  the smallest value in our expression.  A=Min(50,150) will place a value of
  2966. '  50 in the variable A.  Simple!  There is also an exact opposite of this 
  2967. '  command - 'Max'.  Do please remember them as they can come in useful. 
  2968. '
  2969.    Ink 0,0
  2970.    Bar 13,8 To 217,159
  2971.    Ink FC,BC
  2972.    Bar 8,3 To 212,159
  2973.    Ink BC,FC
  2974.    Box 9,4 To 211,158
  2975.    Box 12,108 To 208,155
  2976.    Ink BC,FC
  2977.    A=0
  2978.    Repeat 
  2979.       Bar 15+A*20,6 To 30+A*20,104
  2980.       Set Zone A+1,15+A*20,6 To 30+A*20,104
  2981.       Inc A
  2982.    Until A=3
  2983.    A=0
  2984.    Repeat 
  2985.       Draw 10,6+A*6 To 75,6+A*6
  2986.       Inc A
  2987.    Until A=17
  2988.    A=CL1
  2989.    Repeat 
  2990.       Ink A,A : X=A mod 8 : Y=A/8
  2991.       Bar X*16+80,Y*16+8 To X*16+95,Y*16+23
  2992.       Set Zone A+4,X*16+80,Y*16+8 To X*16+95,Y*16+23
  2993.       RGB(A)=Colour(A)
  2994.    Inc A : 
  2995.    Until A>=Min(32,CL2)
  2996.    Ink BC,FC
  2997.    Box 79,7 To 96+16*X,24+16*Y
  2998. '
  2999. '  It's here that we paste the bobs that represent our buttons.
  3000. '
  3001.    Paste Bob 85,90,45
  3002.    Paste Bob 151,90,55
  3003.    Paste Bob 24,137,56
  3004.    Paste Bob 84,137,57
  3005.    Paste Bob 144,137,58
  3006. '
  3007. '  And print a title above them
  3008. '
  3009.    Locate 2,15 : Print "Preset Palette Selection"
  3010. '
  3011. '  Then we set up some zones around our buttons. 
  3012. '
  3013.    Set Zone 36,80,90 To 140,100
  3014.    Set Zone 37,152,90 To 202,100
  3015.    Set Zone 41,24,137 To 74,149
  3016.    Set Zone 42,84,137 To 134,149
  3017.    Set Zone 43,144,137 To 184,149
  3018.    Ink SELCOL
  3019.    Bar 195,78 To 201,87
  3020.    Ink BC : Box 194,77 To 202,88
  3021.    RGB2[SELCOL]
  3022. '
  3023. '  Now we start the main program loop, which will cycle until the variable 
  3024. '  OK does not equal 0.
  3025. '
  3026.    OK=0
  3027.    While OK=0
  3028. '
  3029. '  Now we have another 'While/Wend' loop that will cycle until the user  
  3030. '  presses a key.  Then the rest of the line loads the YM variable with the
  3031. '  Y co-ordinate of the mouse, and Z with the mouse zone at the time of
  3032. '  clicking
  3033. '
  3034.       While Mouse Key=0 : Wend : YM=Y Screen(Y Mouse) : Z=Mouse Zone
  3035. '
  3036. '  Now we come to check to Z variable in turn. First checking for a value
  3037. '  of 41.
  3038. '
  3039.       If Z=41
  3040. '  
  3041. '  Firstly we paste the highlighted bob for the rainbow button because we
  3042. '  know the left mouse key has been pressed
  3043. '
  3044.          Paste Bob 24,137,62
  3045. '
  3046. '  Then we immediately start another loop that wait for the left mouse key 
  3047. '  to be released.  When it is released we paste an un-highlighted bob over
  3048. '  the last. 
  3049. '
  3050.          While Mouse Key=1 : Wend : Paste Bob 24,137,56
  3051. '
  3052. '  Now this next command holds the key to this function - creating a rainbow 
  3053. '  palette.  This is immensely easy, I simply loaded Photon Paint 2 (sorry EA) 
  3054. '  and wrote down the values for the range of colours I thought best 
  3055. '  represented a rainbow.  Then, as this program is strictly 64 colours (EHB)
  3056. '  I just put those numbers in the next line - 32 colours, becuase Extra Half
  3057. '  bright only generates the other 32 from the first 32.  Please note that the 
  3058. '  next line is considerably larger than the display and can be scrolled.
  3059. '
  3060.          Palette $0,$AAA,$555,$FFF,$F00,$F20,$F40,$F60,$0,$FB0,$FD0,$FF0,$DF0,$BF0,$9F0,$7F0,$0,$4F0,$2F0,$F0,$F2,$F2,$F6,$F9,$FB,$FD,$FF,$BF,$9F,$7F,$6F,$2F
  3061. '
  3062. '  And now we end with the next command.  Yes, this is an 'If/Endif' test, 
  3063. '  if your unfaimilier with them, then let me explain that they are exactly
  3064. '  the same as the conventional logical test of an 'If/Then' condition except
  3065. '  that you can put the whole test on multiple lines, even nest them inside
  3066. '  each other. 
  3067. '
  3068.       End If 
  3069. '
  3070. '  Now we come to the next check on the Z variable.
  3071. '
  3072.       If Z=42
  3073. '
  3074. '  This condition is used to change the palette to grey scales.  The same
  3075. '  method as above was used to get the colour values, and the rest is
  3076. '  identical.
  3077. '
  3078.          Paste Bob 84,137,63
  3079.          While Mouse Key=1 : Wend : Paste Bob 84,137,57
  3080.          Palette $0,$AAA,$555,$FFF,$111,$222,$333,$444,$0,$666,$777,$888,$999,$AAA,$BBB,$CCC,$0,$EEE
  3081.       End If 
  3082. '
  3083. '  The next Z variable check 
  3084. '
  3085.       If Z=43
  3086. '
  3087. '  @@@@  No random palette in  there yet AL !!!!!!!!!!!!!! 
  3088. '
  3089.          Paste Bob 144,137,64
  3090.          While Mouse Key=1 : Wend : Paste Bob 144,137,58
  3091.       End If 
  3092. '
  3093. '  Now we check for a value greater than 0 but less than 4.  This will tell
  3094. '  us if the user has clicked on either of the RGB colour slider to the left 
  3095. '  of the palette selector.
  3096. '
  3097.       If Z>0 and Z<4
  3098. '
  3099. '  If we get inside here by satisfying the above condition the we need to call 
  3100. '  the procedure that takes care of the RGB sliders.  Remember that variable   
  3101. '  descriptions can be found in the Easy Paint Literature. 
  3102. '
  3103.          RGB1[SELCOL,Z-1,YM]
  3104.          RGB2[SELCOL]
  3105. '
  3106. '  And then end
  3107. '
  3108.       End If 
  3109. '
  3110. '  Now if Z is less than 36 and greater than 3 then we know that the user has
  3111. '  clicked on one of the 32 colour boxes.
  3112. '
  3113.       If Z>3 and Z<36
  3114. '
  3115. '  We can of course now change the SELCOL (selected colour) variable to the
  3116. '  ink colour of the box the user clicked on by subtracting 4 from the Z 
  3117. '  variable. As the zone numbers of the colour boxes start at 4 this will give 
  3118. '  us the exact colour value.
  3119. '
  3120.         SELCOL=Z-4
  3121. '
  3122. '  Now we can change the current ink colour to the newly selected colour held
  3123. '  in the SELCOL variable. 
  3124. '
  3125.          Ink SELCOL
  3126. '
  3127. '  Then we draw a small box with the next command next to the hexadecimal
  3128. '  value of the colour, in the newly selected ink colour 
  3129. '
  3130.          Bar 195,78 To 201,87
  3131. '
  3132. '  Now a quick jump to the SFADERS procedure, passing the SELCOL variable
  3133. '  directly into the procedure.  This is used to refresh the palette 
  3134. '  selectors display, i.e. display the hexadecimal value of the new colour etc 
  3135. '
  3136.          RGB2[SELCOL]
  3137.          Ink SELCOL
  3138. '
  3139. '  And then end. 
  3140. '
  3141.       End If 
  3142. '
  3143.       If Z=37
  3144. '
  3145. '  If the user has clicked the 'Use' button on zone 37 then we know that he
  3146. '  wants to use the palette he has affected, so we simply end this check and 
  3147. '  indeed the whole procedure without further ado by first setting the OK
  3148. '  variable to 1 - remember this is the variable this procedure repeatedly 
  3149. '  checks to see if it should end itself...
  3150. '
  3151.          Paste Bob 151,90,61
  3152.          While Mouse Key=1 : Wend : Paste Bob 151,90,55
  3153.          OK=1
  3154. '
  3155. '  And then ending here. 
  3156. '
  3157.       End If 
  3158. '
  3159. '  Should the user wish to exit from the pallete selector without making a 
  3160. '  permanent palette change even though he may have altered a few colours we 
  3161. '  need to get the original palette back with the next test. 
  3162. '
  3163.       If Z=36
  3164.          Paste Bob 85,90,51
  3165.          While Mouse Key=1 : Wend : Paste Bob 85,90,45
  3166.          A=CL1
  3167. '
  3168. '  This 'Repeat/Until' loop will take care of this for us by repeatedly
  3169. '  calling the SPCOL procedure and grabbing the original palette from memory 
  3170. '  
  3171. Repeat 
  3172.             Colour A,RGB(A) : RGB3[A,RGB(A)]
  3173.          Inc A : 
  3174. Until A>=Min(32,CL2)
  3175. '
  3176. '  We also need to tell the procedure to end by setting the OK variable to 1 
  3177. '  in the next line ...
  3178. '
  3179.          OK=1
  3180. '
  3181. '  And end 
  3182. '
  3183.       End If 
  3184. '
  3185. '  Next is the other part of this procedures main 'While/Wend' loop.  Do 
  3186. '  please remember that when we send the program back up there with this next
  3187. '  command, it will check the OK variable, and if it equals 1 then it will 
  3188. '  jump straight back down to ...  
  3189. '
  3190.    Wend 
  3191. '
  3192. '  ... HERE !!! Hello again.  After all this we need get the palette back
  3193. '  into memory for future use with the following bit of program.  Read the 
  3194. '  variable list supplied with the package for information on these .. and 
  3195. '  other variable meanings.  The rest is easy ...
  3196. '
  3197.    Screen 0
  3198.    Get Palette 3
  3199.    T=TPAL : If NCOLS>16 : T=0 : End If 
  3200.    For A=0 To NCOLS-1
  3201.       RGB3[A+T*16,Colour(A)]
  3202.       If TPAL=1 and A<16
  3203.          Colour 16+A,Colour(A)
  3204.          RGB3[A,TPAL(A)]
  3205.       End If 
  3206.    Next A
  3207.    Screen Close 3
  3208.    Screen SC
  3209. '
  3210. '  The end .. of that! 
  3211. '
  3212. End Proc
  3213. '
  3214. '  And the next procedure is simply used to initialise variables that will 
  3215. '  be used by the other RGB* procedures.  Nothing to document really as the
  3216. '  variables are listed in the supplied variable table.
  3217. '
  3218. Procedure RGB1[S,F,YM]
  3219.    Dim R(2)
  3220.    C=Colour(S)
  3221.    R(0)=C/256
  3222.    R(1)=(C/16) mod 16
  3223.    R(2)=C mod 16
  3224.    V=Max(0,Min(15,15-(YM-7)/6))
  3225.    R(F)=V
  3226.    Screen 0
  3227.    Colour S,(R(0)*256+R(1)*16+R(2))
  3228.    Screen 3
  3229.    Colour S,(R(0)*256+R(1)*16+R(2))
  3230.    RGB3[S,Colour(S)]
  3231. End Proc
  3232. '
  3233. '  The next procedure prints the colour number and hex value on the screen 
  3234. '  as well as redrawing the colour slider.  It will also draw the three  
  3235. '  colour sliders at relative positions depending on the colour value we 
  3236. '  pass into the procedure in the variable S 
  3237. '
  3238. Procedure RGB2[S]
  3239. '
  3240. '  First we need to assign some variables, share and dimension them. 
  3241. '
  3242.    Shared RGBO,BC,FC
  3243.    Dim R(2)
  3244.    C=RGBO
  3245.    R(0)=C/256
  3246. '  
  3247. '  Remember that the mod funtion will return the remainder of a division 
  3248. '  only and is not listed in the AMOS User Guide 
  3249. '
  3250.    R(1)=(C/16) mod 16
  3251.    R(2)=C mod 16
  3252.    Ink BC,BC
  3253. '
  3254. '  We reset the A variable because it is used as a counter in the next loop
  3255. '
  3256.    A=0
  3257. '
  3258. '  We now initialise a loop that will draw the slider bars at positions
  3259. '  relative to the colour value.  Try not to get bogged down in the maths
  3260. '  and I wont try to explain it!  This part only erases the last boxes by
  3261. '  drawing bars in the background colour 
  3262. '
  3263.    Repeat 
  3264.       V=(15-R(A))*6 : Bar 17+20*A,7+V To 28+20*A,12+V
  3265.       Inc A
  3266.    Until A=3
  3267. '
  3268. '  The next line will return the amigas colour index from a given value -
  3269. '  which we pass into this procedure in the S variable.  Later we will use 
  3270. '  the new C variable to get the Hex value of a given colour.
  3271. '
  3272.    C=Colour(S)
  3273. '
  3274. '  And now we set some more variables
  3275. '
  3276.    RGBO=C
  3277.    R(0)=C/256
  3278.    R(1)=(C/16) mod 16
  3279.    R(2)=C mod 16
  3280. '
  3281. '  Change the ink and paper colours in one convenient command
  3282. '
  3283.    Ink BC,FC
  3284. '
  3285. '  And next we display our titles and values.  Note the hexadecimal conversion 
  3286. '  of the RGBO variable later in the line.  Remember that we got the RGBO  
  3287. '  variable from the C variable earlier in the program.
  3288. '
  3289.    Text 80,85," Col:"+Right$(" "+Str$(S),2)+"   $"+Right$("000"+Mid$(Hex$(RGBO),2),3)
  3290.    Ink FC,FC
  3291. '
  3292. '  Initialise the A variable again because we will be using it as a counter
  3293. '
  3294.    A=0
  3295. '
  3296. '  Now we start up a loop that will draw in the slider buttons in the correct
  3297. '  foreground colour 
  3298. '
  3299.    Repeat 
  3300. '
  3301. '  And here we set both paper and ink to the current foreground colour 
  3302. '
  3303.       Ink FC,FC
  3304. '
  3305. '  Next we draw a box around the slider bar
  3306. '
  3307.       V=(15-R(A))*6 : Box 17+20*A,7+V To 28+20*A,12+V
  3308. '
  3309. '  Now we change to the current ink colour RGB seperation
  3310. '
  3311.       Ink S
  3312. '
  3313. '  And fill inside the above box with a bar of colour
  3314. '
  3315.       Bar 18+20*A,8+V To 27+20*A,11+V
  3316. '
  3317. '  Then increment the A variable 
  3318. '
  3319.       Inc A
  3320. '
  3321. '  And check it
  3322. '
  3323.    Until A=3
  3324. '
  3325. '  Then end this procedure 
  3326. '
  3327. End Proc
  3328. '
  3329. '  The next procedure simply 'Doke's the palette into memory so we always have 
  3330. '  a copy that isn't immediately changeable. 
  3331. '
  3332. Procedure RGB3[A,B]
  3333.    If Length(1)>0
  3334.       Doke Start(1)+2+8*Length(1)+2*A,B
  3335.    End If 
  3336. End Proc
  3337. '
  3338. '  This procedure is very simple, when I started this project I wrote down 
  3339. '  all the values of the palette I was using and put them in here, so at any 
  3340. '  time the user can call this procedure and restore the palette to its
  3341. '  default standard
  3342. '
  3343. Procedure DEFPALETTE
  3344. '
  3345.    Palette $0,$AAA,$555,$FFF,$808,$F4A,$E00,$620,$0,$FA8,$FE0,$80,$D0,$CC,$6F,$A,$0,$EC8,$C60,$EA0,$27F,$49D,$5AE,$ADF
  3346. '
  3347. '  All the commas are simply representing the spaces of the above numbers
  3348. '  as we have just set them up we dont want to change them again.  Yes, you
  3349. '  could put all the values on one line. 
  3350. '
  3351.    Palette ,,,,,,,,,,,,,,,,,,,,,,,,$BDF,$CEF,$FFF,$408,$ADE,$E0E,$E08,$EEE
  3352. End Proc
  3353. '
  3354. '  This procedure halfs the size of the current brush by using the 'Zoom'
  3355. '  command to make an image on a seperate screen, and then grabbing the
  3356. '  brush again from the new co-ordinates.  Variable descriptions are listed
  3357. '  in the supplied variable table
  3358. '
  3359. Procedure BHALF
  3360.    Screen Open 3,320,256,64,Lowres : Cls 0
  3361.    Get Sprite Palette 
  3362.    Screen Open 4,320,256,64,Lowres : Cls 0
  3363.    Get Sprite Palette 
  3364.    Screen 3 : Paste Bob BX,BY,80
  3365.    Zoom 3,BX,BY,BX1,BY1 To 4,BX,BY,BX1/2+BX/2,BY1/2+BY/2
  3366.    Get Bob 4,80,BX,BY To BX1/2+BX/2,BY1/2+BY/2
  3367.    Screen Close 4
  3368.    Screen Close 3
  3369. End Proc
  3370. '
  3371. '  This procedure doubles the size of the current brush by using the 'Zoom'
  3372. '  command to make an image on a seperate screen, and then grabbing the
  3373. '  brush again from the new co-ordinates.  Variable descriptions are listed
  3374. '  in the supplied variable table
  3375. '
  3376. Procedure BDOUBLE
  3377.    Screen Open 3,320,256,64,Lowres : Cls 0
  3378.    Get Sprite Palette 
  3379.    Screen Open 4,320,256,64,Lowres : Cls 0
  3380.    Get Sprite Palette 
  3381.    Screen 3 : Paste Bob 0,0,80
  3382.    Zoom 3,0,0,BX1-BX,BY1-BY To 4,0,0,BX1*2-BX*2,BY1*2-BY*2
  3383.    Get Bob 4,80,0,0 To BX1*2-BX*2,BY1*2-BY*2
  3384.    Screen Close 4
  3385.    Screen Close 3
  3386. End Proc
  3387. '
  3388. '  This procedure doubles the size of the current brush horizontally by  
  3389. '  using the 'Zoom' command to make an image on a seperate screen, and then  
  3390. '  grabbing the brush again from the new co-ordinates.  Variable descriptions  
  3391. '  are listed in the supplied variable table 
  3392. '
  3393. Procedure BDOUBLEHORIZ
  3394.    Screen Open 3,320,256,64,Lowres : Cls 0
  3395.    Get Sprite Palette 
  3396.    Screen Open 4,320,256,64,Lowres : Cls 0
  3397.    Get Sprite Palette 
  3398.    Screen 3 : Paste Bob 0,0,80
  3399.    Zoom 3,0,0,BX1-BX,BY1-BY To 4,0,0,BX1*2-BX*2,BY1-BY
  3400.    Get Bob 4,80,0,0 To BX1*2-BX*2,BY1-BY
  3401.    Screen Close 4
  3402.    Screen Close 3
  3403. End Proc
  3404. '
  3405. '  This procedure doubles the size of the current brush vertically by  
  3406. '  using the 'Zoom' command to make an image on a seperate screen, and then  
  3407. '  grabbing the brush again from the new co-ordinates.  Variable descriptions  
  3408. '  are listed in the supplied variable table 
  3409. '
  3410. '
  3411. Procedure BDOUBLEVERT
  3412.    Screen Open 3,320,256,64,Lowres : Cls 0
  3413.    Get Sprite Palette 
  3414.    Screen Open 4,320,256,64,Lowres : Cls 0
  3415.    Get Sprite Palette 
  3416.    Screen 3 : Paste Bob 0,0,80
  3417.    Zoom 3,0,0,BX1-BX,BY1-BY To 4,0,0,BX1-BX,BY1*2-BY*2
  3418.    Get Bob 4,80,0,0 To BX1-BX,BY1*2-BY*2
  3419.    Screen Close 4
  3420.    Screen Close 3
  3421. End Proc
  3422. '
  3423. '  This next procedure allows us to input any information at any position on 
  3424. '  the screen and of any set length - the variables we pass into it as A,  
  3425. '  B and LEANTH
  3426. '
  3427. Procedure LININPUT[A,B,LEANTH]
  3428. '
  3429. '  We start by setting the paper colour to 0 and locating the text cursor at 
  3430. '  the positions we passed into this procedure - A and B, and then printing
  3431. '  LEANTH number of spaces at this position to clear any text that may have
  3432. '  already been there. 
  3433. '
  3434.    Paper 0 : Locate A,B : Print Space$(LEANTH)
  3435. '
  3436. '  Then wait half a second 
  3437. '
  3438.    Wait 25
  3439. '
  3440. '  And clear the keyboard buffer.  Reason ? Well, everytime you press a key
  3441. '  on the keyboard, regardless of whether you are in this procedure or not,  
  3442. '  the key press gets put into a buffer ( a piece of memory ), and when we 
  3443. '  then read this buffer we get old information - which we don't want. 
  3444. '
  3445. Clear Key 
  3446. '
  3447. '  When this procedure has finished it places the information the user input 
  3448. '  into the variable FIN$ so it can be read by the calling procedure.  We  
  3449. '  also clear this variable for the same reasons by loading it with nothing
  3450. '
  3451.    FIN$=""
  3452. '
  3453. '  Now we relocate the text cursor to our location variables.
  3454. '
  3455.    Locate A,B
  3456. '
  3457. '  And set up our main loop to cycle until the required number of characters 
  3458. '  have been input.
  3459. '
  3460.    For LOP=A To LEANTH+A
  3461. '
  3462. '  We will also use the next label to jump back to in the event we do not
  3463. '  need or want to increment the main loop,e.g if the delete key is pressed
  3464. '
  3465.       LINE1:
  3466. '
  3467. '  Now we read the keyboard input into the N$ variable.  Inkey$ will only grab 
  3468. '  one key press at a time.
  3469. '
  3470.       N$=Inkey$
  3471. '
  3472. '  I have also taken any mouse key as a return press, so we can check that if
  3473. '  a mouse key has been pressed then we need to end this loop by jumping to  
  3474. '  the LINE2 label 
  3475. '
  3476.       If Mouse Key<>0 Then Goto LINE2 : 
  3477. '
  3478. '  Whereas if the N$ variable is empty we know that no key has been pressed
  3479. '  so we jump back to the LINE1 label until a key IS pressed ! 
  3480. '
  3481.       If N$="" Then Goto LINE1 : 
  3482. '
  3483. '  So here we know a key has been pressed and we need to know if it is an
  3484. '  important key like Delete/Back Space or Return.  The next line gets an
  3485. '  ASCII value of N$(the pressed key) and checks for a value of 8 which we 
  3486. '  know represents the delete key.  If this test is true then we need to 
  3487. '  print a space over the previous charater on the display, and then delete it 
  3488. '  from the FIN$ variable that holds the complete input.  We must also 
  3489. '  decrement the loop after checking that it is greater than the A variable  
  3490. '
  3491.       If Asc(N$)=8 and LOP>A Then LOP=LOP-1 : Locate LOP,B : Print " " : FIN$=Mid$(FIN$,1,Len(FIN$)-1) : Goto LINE1
  3492. '
  3493. '  Again we check the ASCII value of N$ for a content of 13.  If the test is 
  3494. '  true then we know the return key has been pressed to end the input, now we
  3495. '  must jump to the LINE2 label
  3496. '
  3497.       If Asc(N$)=13 Then Goto LINE2
  3498. '
  3499. '  Next we can check if the loop (LOP) is less than LEANTH+A (LEANTH+A giving  
  3500. '  us the correct user specified input length) and if this test is true we can 
  3501. '  add the last keypress (N$) to our output variable (FIN$)
  3502.       If LOP<LEANTH+A Then FIN$=FIN$+N$
  3503. '
  3504. '  Now if the loop counter is equal the the maximum user specified input 
  3505. '  length then we will have to decrement the loop counter so as not to 
  3506. '  exceed the correct input length.
  3507. '
  3508.       If LOP=LEANTH+A Then LOP=LOP-1
  3509. '
  3510. '  Then we display the last keypress LOP columns in and B Rows down. 
  3511. '
  3512.       Locate LOP,B : Print N$
  3513. '
  3514. '  We can also remember the last keypress by placing it into the LAST$ 
  3515. '  variable. 
  3516. '
  3517.       LAST$=N$
  3518. '
  3519. '  Then we can send the loop back again
  3520. '
  3521.    Next LOP
  3522. '
  3523.    LINE2:
  3524. '
  3525. '  Before we end we must place the last inputted character onto the end of 
  3526. '  our output string as the main program will not have had time to do this 
  3527. '
  3528.    If LOP=LEANTH+A Then FIN$=FIN$+LAST$
  3529. '
  3530. '  And then end this procedure.
  3531. '
  3532. End Proc
  3533. '
  3534. '   Next is a three liner that simply returns the program to the next  
  3535. '   instruction after an error is generated
  3536. '
  3537. Procedure SWERROR
  3538. '
  3539. '  The following command takes care of this for us.
  3540. '
  3541.    Resume Next 
  3542. '
  3543. End Proc
  3544. '
  3545. '  And the next procedure does all the drawing of the main drawing screen, 
  3546. '  pasting the buttons, setting zones and drawing the title bar. 
  3547. '
  3548. Procedure SETUPSCREEN
  3549. '
  3550. '  First we reserve the zones that will be used by the buttons on the menu 
  3551. '  bar 
  3552. '
  3553.    Reserve Zone 25
  3554. '
  3555. '  Then we draw the top title bar ...
  3556. '
  3557.    Ink 1 : Bar 0,0 To 316,9
  3558.    Ink 3 : Draw 0,0 To 0,9
  3559.    Ink 3 : Draw 0,0 To 316,0
  3560.    Ink 2 : Draw 0,9 To 316,9
  3561.    Ink 2 : Draw 316,9 To 316,0
  3562. '
  3563. '  And display the programs name 
  3564. '
  3565. If PAGE=0 Then PAGE$="Default " Else PAGE$="Scribble"
  3566.    Ink 0 : Text 7,7,"EasyPaint   "+PAGE$
  3567. '
  3568. '   Paste Menu Bobs and set up the respective zones
  3569. '
  3570.    Paste Bob 292,11,1
  3571.    Set Zone 1,292,11 To 318,35
  3572.    W=2
  3573.    For Y=36 To 140 Step 13
  3574.       For X=292 To 305 Step 13
  3575.          Set Zone W,X,Y To X+13,Y+13
  3576.          Read Z
  3577.          Paste Bob X,Y,Z
  3578.          Inc W
  3579.       Next X
  3580.    Next Y
  3581. '
  3582. '  I used a data statement here for order of bobs pasted 
  3583. '
  3584.    Data 2,3,6,7,4,5,16,9,10,11,18,8,12,13,72,17,14,15
  3585.    IK=0
  3586.    Set Zone 22,292,166 To 312,258
  3587.    Ink 60 : Bar 291,165 To 316,260
  3588.    Box 0,10 To 290,263 : Rem drawing area perimeter 
  3589. '
  3590. '  And here is a couple of loops (nested) that draw the coloured boxes on to 
  3591. '  the menu bar
  3592. '
  3593.    For X=292 To 312 Step 6
  3594.       For Y=166 To 258 Step 6
  3595.          Ink IK
  3596.          Inc IK
  3597.          Bar X,Y To X+5,Y+5
  3598.       Next Y
  3599.    Next X
  3600.    XB=-20 : YB=-20 : BO=2
  3601. Proc ZCOLBAR
  3602. '
  3603. '  That's it folks 
  3604. '
  3605. End Proc
  3606. '
  3607. '  The final procedure !!!!! Hey, I know - It's been great, but let me just  
  3608. '  explain.  This procedure checks the zones of each button on the menu bar
  3609. '  and then calls the relevant procedure.  If you read the variable table
  3610. '  you'll find that there is no need for more than what I've put in the
  3611. '  procedure.  It is simply checking the contents of variables and changeing 
  3612. '  some accordingly. 
  3613. '
  3614. Procedure CHECKZONES
  3615. '
  3616. '  But first we cycle through a loop until the left mouse key is pressed 
  3617. '
  3618.    Repeat 
  3619. '
  3620. '  While checing in here if the crosshairs have been activated and then  
  3621. '  jumping to the crosshairs procedure if they have. 
  3622. '
  3623.       If CROSS=1 Then Proc CROSSHAIRS
  3624.       Z=Mouse Zone
  3625.    Until Mouse Key=1
  3626. '
  3627.    11 If Z=2 Then PROG=2
  3628.    22 If Z=3 and PROG=3 and F2TYPE=0 Then F2TYPE=1 : PROG=3 : Goto 55
  3629.    If Z=3 and PROG=3 and F2TYPE=1 Then F2TYPE=0 : PROG=3 : Goto 55
  3630.    If Z=3 and PROG<>3 Then F2TYPE=0 : PROG=3
  3631.    If Z=4 Then PROG=4
  3632.    If Z=5 Then PROG=5
  3633.    77 If Z=6 and PROG=6 and F5TYPE=0 Then F5TYPE=1 : PROG=6 : Goto 88
  3634.    If Z=6 and PROG=6 and F5TYPE=1 Then F5TYPE=0 : PROG=6 : Goto 88
  3635.    If Z=6 and PROG<>6 Then F5TYPE=0 : PROG=6
  3636.    88 If Z=7 and PROG=7 and F6TYPE=0 Then F6TYPE=1 : PROG=7 : Goto 99
  3637.    If Z=7 and PROG=7 and F6TYPE=1 Then F6TYPE=0 : PROG=7 : Goto 99
  3638.    If Z=7 and PROG<>7 Then F6TYPE=0 : PROG=7
  3639.    99 If Z=8 and PROG=8 and F7TYPE=0 Then F7TYPE=1 : PROG=8 : Goto 55
  3640.    If Z=8 and PROG=8 and F7TYPE=1 Then F7TYPE=0 : PROG=8 : Goto 55
  3641.    If Z=8 and PROG<>8 Then F7TYPE=0 : PROG=8
  3642.    55 If Z=9 and PROG=9 and F8TYPE=0 Then F8TYPE=1 : PROG=9 : Goto 66
  3643.    If Z=9 and PROG=9 and F8TYPE=1 Then F8TYPE=0 : PROG=9 : Goto 66
  3644.    If Z=9 and PROG<>9 Then F8TYPE=0 : PROG=9
  3645.    66 If Z=12 Then PROG=12
  3646.    If Z<>18 and Z<>0 Then Screen Copy 0,0,11,289,263 To 1,0,11
  3647.    If Z=22 Then I=Point(X Screen(X Mouse),Y Screen(Y Mouse)) : Ink I
  3648.    Wait 3
  3649.    If Z<13 and PROG<>0 and Z<>10 and Z<>11 Then Z=PROG
  3650. If Z=0 and PROG=20 Then Z=PROG
  3651. Proc ZCOLBAR
  3652. On Z Proc CHECKZONES,FREHANDDOT,CONTINUOUSFREEHAND,STRAIGHTLINE,F4,FCIRCLE,FBOX,FELLIPSE,FPOLYGON,FCROSS,F10,FFILL,FBRUSHCUTTER,F13,F14,F15,F16,FUNDO,FCLS,AIRBRUSH
  3653. End Proc
  3654. '
  3655. '
  3656. '
  3657. Procedure FASTZOOM
  3658. MP=4 : Rem magnification power! 
  3659.       Dreg(1)=MP
  3660.       Dreg(2)=WIDTH : Dreg(3)=HEIGHT
  3661.       Dreg(4)=16 : Dreg(5)=32 : Rem these two hold the top left co-ords of the zoom too box
  3662.       Dreg(6)=32 : Dreg(7)=32 : Rem these hold the size of the zoom too box, the values are double each single pixel 
  3663.       Areg(0)=Screen Base
  3664.       Call 10
  3665.    Screen 0
  3666. End Proc
  3667. Procedure ZCOLBAR
  3668. Ink BC : Bar 292,153 To 316,163
  3669. Ink I : Bar 298,156 To 309,160
  3670. End Proc
  3671. Procedure AIRPOWER
  3672. Get Cblock 1,32,32,164,116
  3673. Ink 1 : Bar 32,32 To 164,116
  3674. Ink 3 : Polyline 32,116 To 32,32 To 164,32
  3675. Ink 2 : Polyline 164,33 To 164,116 To 33,116
  3676. Locate 5,5 : Paper 1 : Print "Airbrush Power"
  3677. Bob 75,DENSITY+42,90,74
  3678. Ink 0 : Bar 40,88 To 155,103
  3679. Box 38,86 To 157,105
  3680. Bar 47,61 To 81,73
  3681. Box 45,59 To 83,75
  3682. K$=Str$(DENSITY)-" "
  3683. Locate 6,8 : Paper 0 : Print K$ : Locate 9,8 : Print "%"
  3684. Paste Bob 100,61,55
  3685. BEGIN: While Mouse Key=1
  3686. If X Screen(X Mouse)>100 and Y Screen(Y Mouse)>61 and X Screen(X Mouse)<157 and Y Screen(Y Mouse)<73 Then Goto FINISHED
  3687. X1=X Screen(X Mouse) : If X1=X and Mouse Key=1 Then Goto BEGIN
  3688. X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  3689. If X>142 or X<42 or Y<90 or Y>101 Then Goto BEGIN
  3690. Bob 75,X,90,74
  3691. Locate 6,8 : Print "    "
  3692. K$=Str$(X-42)-" "
  3693. Locate 6,8 : Paper 0 : Print K$ : Locate 9,8 : Print "%"
  3694. DENSITY=X-42
  3695. Wend 
  3696. Goto BEGIN : 
  3697. FINISHED:
  3698. Put Cblock 1
  3699. Del Cblock 
  3700. Proc AIRBRUSH
  3701. End Proc